Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    perryc is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2019
    Posts
    122

    Form showing #Name? when search for a record


    I am struggling to understand why a form, based on a query linking 2 tables (Main Form with zip code and 2nd form zip code with city name and county). When I display the form (while entering the zip code in the main form, the 2nd form city and county will be pulled in. I can reopen the main form and the city and county will be there... However, when I search for a particular record, then, the city and county won't show but #name? on both. Why is that and how to fix that? Thanks in advance.

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    usually means that access doesn't understand whatever you have in the controlsource - typically a misspelling, the relevant field not in the recordsource or if a calculation/domain query, an error in its construction (i.e. would be reported as a syntax error if it was in vba)

  3. #3
    perryc is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2019
    Posts
    122
    Quote Originally Posted by Ajax View Post
    usually means that access doesn't understand whatever you have in the controlsource - typically a misspelling, the relevant field not in the recordsource or if a calculation/domain query, an error in its construction (i.e. would be reported as a syntax error if it was in vba)
    Ty for a quick response. This is really strange cause it is a simple query like I originally said that bring values from 2 tables into one form. (zip and city) The #name? only happens when I bring that form to live via codes below:

    Dim PCriteria As String

    DoCmd.OpenForm "Form1"
    Form_Form1.RecordSource = "select * from Referrals where " & PCriteria

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    you have not assigned a value to PCriteria

  5. #5
    perryc is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2019
    Posts
    122
    Quote Originally Posted by Ajax View Post
    you have not assigned a value to PCriteria
    I am sorry I neglected to include that piece. Here is a complete code:

    Dim PCriteria As String

    PCriteria = "Patient" & " LIKE '*" & Patient & "*'"

    DoCmd.OpenForm "Form1"
    Form_Form1.RecordSource = "select * from Referrals where " & PCriteria

  6. #6
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    your first post could be interpreted to mean there is a subform involved but you're not clear about the relationship between the 2 forms involved.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    you can either use

    DoCmd.OpenForm "Form1"
    Forms!Form1.Recordsource=

    or

    Forms("Form1").Recordsource=


  8. #8
    perryc is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2019
    Posts
    122
    Quote Originally Posted by Ajax View Post
    you can either use

    DoCmd.OpenForm "Form1"
    Forms!Form1.Recordsource=

    or

    Forms("Form1").Recordsource=


    Thanks but these did not help. (p.s. the team is from the same zip, city table.)
    Click image for larger version. 

Name:	CapIssue.PNG 
Views:	15 
Size:	1.9 KB 
ID:	37918

  9. #9
    perryc is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2019
    Posts
    122
    No, there is no subform. As far as the relationship:

    Click image for larger version. 

Name:	CapRelationship.PNG 
Views:	15 
Size:	26.2 KB 
ID:	37919

  10. #10
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    you are not showing the information that matters - what are the actual names of your fields and what are the actual controlsources in your form controls

  11. #11
    perryc is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2019
    Posts
    122
    Names of the field: City and Team

    Actual ControlSources: None. Just these codes to call the form. I am not sure what exactly do you mean. If you mean where the source is coming from, it is from a query that contains those 2 tables with a joint property I captured above. (Table1 Referrals; Table2 Zip&Team)

  12. #12
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    if the controlsources are blank then you would display a blank, not #error.

    open the form in design view, open the properties window if not already open and select the data tab. Then click on one of the controls which display #error - you will see the controlsource there

  13. #13
    perryc is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2019
    Posts
    122
    Quote Originally Posted by Ajax View Post
    if the controlsources are blank then you would display a blank, not #error.

    open the form in design view, open the properties window if not already open and select the data tab. Then click on one of the controls which display #error - you will see the controlsource there
    AJax, ty for your help. So, it was not displaying #error but #Name? Here is the control source: It simply says City (which is the exact name on the table). BTW, like I said, this only happened when I do a search for a record, not when I open the form. Very frustrating.

    Click image for larger version. 

Name:	CaptureControlSource.PNG 
Views:	12 
Size:	3.5 KB 
ID:	37934

  14. #14
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    You need to also show the recordsource to the form - city needs to be there as well

  15. #15
    perryc is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2019
    Posts
    122
    Quote Originally Posted by Ajax View Post
    You need to also show the recordsource to the form - city needs to be there as well

    If you mean in the Query where this recordsource is to the form, yes, it is there. It is part of the query that brings the 2 tables together, and yes, City is in that query (recordsource) to this form.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 02-28-2018, 01:02 PM
  2. Replies: 6
    Last Post: 02-02-2015, 02:14 PM
  3. Replies: 12
    Last Post: 08-17-2013, 11:49 PM
  4. Replies: 6
    Last Post: 10-25-2012, 04:13 AM
  5. Replies: 3
    Last Post: 06-27-2009, 03:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums