Results 1 to 4 of 4
  1. #1
    moneypennie21 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    May 2017
    Posts
    41

    Run time error 2465 - can't find the field '1' referred to in your expression

    I am trying to create a click button event to open a form based on a parameter but keep getting this error Run-Time error '2465' Microsoft access can't find the field '|1' referred to in your expression. the code I'm using is



    Private Sub Command2_Click()


    DoCmd.OpenForm [Visit Data], , , "[Branch code] = '" & Me.Combo0 & "'"




    End Sub



    Visit data is the form - it contains the space in the name (someone else created this database not me) and Branch code is a text field which also has the space in the name of the field

    Any ideas?

    Thanks

    J

  2. #2
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,879
    The form name needs to be in quotes.

    Code:
    DoCmd.OpenForm "[Visit Data]", , , "[Branch code] = '" & Me.Combo0 & "'"

  3. #3
    moneypennie21 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    May 2017
    Posts
    41
    I did try this but then I got a different error saying the form name was misspelled or did not exist however I have realised as this is a simple database I have renamed the form to visit_data - removed the [] and it works now. thanks

    J

  4. #4
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,879
    I should have realized that the brackets were not needed in the form name but the quotes were. I never have spaces in names but you'll see many postings on the forum about them.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 05-04-2019, 09:02 PM
  2. Replies: 14
    Last Post: 05-03-2019, 01:01 PM
  3. Replies: 3
    Last Post: 10-10-2014, 06:29 PM
  4. Replies: 1
    Last Post: 12-01-2012, 12:44 PM
  5. Replies: 5
    Last Post: 06-09-2012, 12:37 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