none
#name error in 2010 form control filled from VBA

    Question

  • Have new machine with Windows 7 Premium and Office Pro 2010 - moving my Access programs from Windows XP and Office 2002.  Screen form has a control with source = prtRptName - This is a string field that was created and filled in VBA code on open of the form - when debug the code you see the correct value in prtRptName but the control displays #name - this is working fine on the old machine and software mentioned above.  Actually there is another field defined in the VBA code in another control which is not being recognized also.

     

    Saturday, September 15, 2012 6:10 PM

Answers

  • I have resolved the problem of the control on the form coming up #name and not displaying the Report Selected Description I loaded in the VBA code - see above

    1) Gave the control a specific name "PrtLongName" and removed a control source then loaded the control from the VBA code as in example below

    --------------------------------------------------------------------------

    If strCallRpt = "AllConsultDate" Then
            PrtRptName = "All Jobs by Consultant Select by Date (#1330)"
            'MediaType.Enabled = False
            GetEstNum.Enabled = False
            BeginYear.Enabled = False
            EndYear.Enabled = False
           
            'Client.Enabled = False
            BrandNam.Enabled = False
            Agency.Enabled = False
            ClientEstNo.Enabled = False
            'Consultant.Enabled = False
        End If
        [Forms]![trackrptselection]![PrtLongName] = PrtRptName
       

    -------------------------------------------------------------------------------------------

    For others reading these threads - I tried importing the tables,forms,queries,reports into a blank 2010 database and that did NOT solve the problem.

    Thank you again for your time on this

    I will mark this as answer and resolve my other problem on holdclient.


    BGBarb

    • Marked as answer by BGBarb Monday, September 17, 2012 7:36 PM
    Monday, September 17, 2012 7:36 PM

All replies

  • Check your References, something might be missing or broken...

    http://www.access-diva.com/d5.html

    You will also want to make sure the database is in a Trusted Location...

    http://www.access-diva.com/d4.html


    --
    Gina Whipp
    Microsoft MVP (Access)

    Please post all replies to the forum where everyone can benefit.

    Saturday, September 15, 2012 6:13 PM
  • I went through all References - None were broken or missing - although I did uncheck VBA for Applications Extensibility5.3 to see ;if that would help.

    Also added the path and file folder where the database resides as a trusted location.

    Neither of these steps solved the problem.


    BGBarb

    Saturday, September 15, 2012 6:58 PM
  • Please list the References you have checked and the order in which they are checked.  And, whatever error message you get now please indicate that with the number, if any...

    --
    Gina Whipp
    Microsoft MVP (Access)

    Please post all replies to the forum where everyone can benefit.

    Saturday, September 15, 2012 7:07 PM
  • References are in this order:

    Visual Basick for Applications

    Microsoft Access 14.0 Object Library

    Microsoft DAO 3.6 Object Library

    OLE Automation

    ------------------------------------------------------------------------------------------------------------------------

    I am not receiving a numbered error - this is a form where the heading I display is the name of a report they have selected (the form is for entering selections for the report they want) Anyway when the form displays,  where the name of report is displayed it says #name. The control on the form has the source line set as =[ PrtRptName] which is a string field defined in the VBA code behind the form.


    BGBarb

    Saturday, September 15, 2012 7:46 PM
  • Re: the references I did recheck Visual Basic for Applications Extensibility 5.3 as on checking my old machine I see that was checked also. It is last in order of the checked references listed above.

     

    BGBarb

    Saturday, September 15, 2012 7:51 PM
  • Go to the report in Design Mode and Debug > Compile.  Make sure Option Explicit is under Option Compare Database.  If that fails to work... Please paste here the string for PrtRptName.

    Also, Visual Basic for Applications Extensibility will be on the old maachine but should *not* be on the new machine.  It will cause problems on the new machine.  Actually, you could leave it unchecked on both machine should not cause a problem.


    --
    Gina Whipp
    Microsoft MVP (Access)

    Please post all replies to the forum where everyone can benefit.

    Saturday, September 15, 2012 8:07 PM
  • Compile worked fine - here is code which uses the prtrptname the control on the screen is just a text field with a name like Test356 and the source line is =prtrptname  I tried to take screen shots of the code and the form but couldn't paste them into this reply box - one more thing to learn properly.  Thank you for your work on this problem.

    Option Compare Database
    Option Explicit
    Dim strCallRpt As String
    Const ConErrRptCanceled = 2501
    Public PrtRptName As String
    Public holdclient As String

     

    Private Sub Client_AfterUpdate()
    holdclient = "  "
    holdclient = Client.Column(0)

    SelDivision.Requery
    End Sub

    Private Sub Form_Current()
       
        PrtRptName = strCallRpt
        If strCallRpt = "EstimateProfile" Then
            PrtRptName = "Header Sheet (#1991)"
            MediaType.Enabled = False
            Status.Enabled = False
            BeginYear.Enabled = False
            EndYear.Enabled = False
            BeginDate.Enabled = False
            EndDate.Enabled = False
            Client.Enabled = False
            ClientEstNo.Enabled = False
           
            BrandNam.Enabled = False
            Agency.Enabled = False
            Consultant.Enabled = False
            SelDivision.Enabled = False
        End If


    BGBarb

    Saturday, September 15, 2012 8:55 PM
  • Yeah, you really can't past images here, you have to link them... another time for that.  In the meantime, try this...
    PrtRptName = strCallRpt
        If strCallRpt = "EstimateProfile" Then
            PrtRptName = "Header Sheet (#1991)"
            MediaType.Enabled = False
            Status.Enabled = False
            BeginYear.Enabled = False
            EndYear.Enabled = False
            BeginDate.Enabled = False
            EndDate.Enabled = False
            Client.Enabled = False
            ClientEstNo.Enabled = False
            
            BrandNam.Enabled = False
            Agency.Enabled = False
            Consultant.Enabled = False
            SelDivision.Enabled = False
        Else
           StrCallRpt = "NotFound"
        End if


    --
    Gina Whipp
    Microsoft MVP (Access)

    Please post all replies to the forum where everyone can benefit.

    Saturday, September 15, 2012 9:55 PM
  • Can't fool with the value of strcallrpt - it really does contain the name of the report program which will be called at end of this form after they have entered their criteria - i.e Client, Division etc. I have debugged this code and prtrptname is being filled with the correct name I want to display on the form.  The problem here is that the front end of the program - The Form - does not recognize variables defined in the background (the VBA code).  For instance here is the other problem I am having with a variable defined in the VBA code.

    I get a client in a unbound field using a query statement.  Then if you'll notice in the code blurb above under Private Sub Client_ AfterUpdate I am moving a value from the client lookup into a variable named holdclient.  Then in the next unbound control on the form I am going to load a list of Divisions that apply to the client they entered using the following as the row source for the Division Control.

    SELECT TVDIV.ADV_CODE, TVDIV.DIVISION_NAME FROM TVDIV WHERE (((TVDIV.ADV_CODE)=holdclient or (tvdiv.adv_code) = "AA")) ORDER BY TVDIV.ADV_CODE;

    On entry of the Division field and this runs the Get Parameter box is displayed asking for holdclient.  So again the form controls are not recognizing fields defined in the VBA code. 

    Does this shed any more light on the problem?


    BGBarb

    Sunday, September 16, 2012 5:10 PM
  • This error usually occurs when the Field Name in the Form's Field's Record Source Property does not match that of the Table or query providing the data.  (Have a look at...http://office.microsoft.com/en-us/access-help/i-see-name-displayed-in-a-control-HA001181447.aspx)  However, in your case that would not be the problem because it was working... UNLESS, did you change anything?


    --
    Gina Whipp
    Microsoft MVP (Access)

    Please post all replies to the forum where everyone can benefit.

    Sunday, September 16, 2012 6:59 PM
  • No I have not changed anything  - just made a copy of my .mdb from my old machine moved it onto my new machine with Windows 7 and Office 2010.  Just wanted to see how print preview looked  in the new Office so called up the report menu, selected a report and the error came up.  If I run on the old machine everything is OK. Old machine is Windiows XP and Office 2002

    BGBarb

    Sunday, September 16, 2012 8:20 PM
  • I'm getting close to being stumped...  Did you add the *Else* portion I suggest?  I would be curious to see if it shows in the Unbound Field.  If, yes, you may have to Step Thru the code to see where it's misfiring.

    --
    Gina Whipp
    Microsoft MVP (Access)

    Please post all replies to the forum where everyone can benefit.

    Sunday, September 16, 2012 9:36 PM
  • Thank you so much for working on this.  I have to be away from my machine for awhile today but will work on this more this afternoon.  Will let you know what I can determine.

    BGBarb

    Monday, September 17, 2012 12:25 PM
  • Just a thought,

    When you say moving from 2002 to 2010, Are you importing the db into an empty 2010 shell? Or just opening an old version of Access with a new version of access?

    If you haven't imported a copy into a new 2010 shell you may wish to try to see what happens after you debug.


    Chris Ward

    Monday, September 17, 2012 1:42 PM
  • I have resolved the problem of the control on the form coming up #name and not displaying the Report Selected Description I loaded in the VBA code - see above

    1) Gave the control a specific name "PrtLongName" and removed a control source then loaded the control from the VBA code as in example below

    --------------------------------------------------------------------------

    If strCallRpt = "AllConsultDate" Then
            PrtRptName = "All Jobs by Consultant Select by Date (#1330)"
            'MediaType.Enabled = False
            GetEstNum.Enabled = False
            BeginYear.Enabled = False
            EndYear.Enabled = False
           
            'Client.Enabled = False
            BrandNam.Enabled = False
            Agency.Enabled = False
            ClientEstNo.Enabled = False
            'Consultant.Enabled = False
        End If
        [Forms]![trackrptselection]![PrtLongName] = PrtRptName
       

    -------------------------------------------------------------------------------------------

    For others reading these threads - I tried importing the tables,forms,queries,reports into a blank 2010 database and that did NOT solve the problem.

    Thank you again for your time on this

    I will mark this as answer and resolve my other problem on holdclient.


    BGBarb

    • Marked as answer by BGBarb Monday, September 17, 2012 7:36 PM
    Monday, September 17, 2012 7:36 PM
  • Thank you for posting back with the Resolution...

    --
    Gina Whipp
    Microsoft MVP (Access)

    Please post all replies to the forum where everyone can benefit.

    Monday, September 17, 2012 7:54 PM