Results 1 to 5 of 5
  1. #1
    mdavid is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2017
    Posts
    160

    error 2465 in combobox after update

    Hi,
    I'm trying to change the content of a listbox in a subform when the selection in the combobox on the main form changes, here's the combobox after update event
    Code:
    Private Sub cmbMempSpecies_AfterUpdate()
        DoCmd.SearchForRecord , "", acFirst, "[SpeciesID] = " & cmbMempSpecies
    Forms![MempBercMainFrm2].[Form]![MempBercListBox].[Form]![lstbMempComplaints].RowSource = "SELECT " _
          & "ComplaintID, SpeciesID, Complaint, Preparation, Administration, " _
          & "ComplaintEdited, PreparationEdited, AdministrationEdited FROM MempComplaintTom " _
          & "WHERE SpeciesID = " & [Me].[SpeciesID]
    Forms![MempBercMainFrm2].[Form]![MempBercListBox].[Form]![lstbMempComplaints].Requery
    End Sub
    I get error 2465: Microsoft Access can't find the field '|1' referred to in your expression

    Red text is highlited

    Any ideas?

    David

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,643
    I'd use a variable for the SQL and this to see how it's ending up:

    http://www.baldyweb.com/ImmediateWindow.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,643
    And "MempBercListBox" is the name of the subform control?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    Micron is online now Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,372
    I say it's because you wrapped Me in square brackets. The first line of your expression doesn't look right either. It almost reads like it's for a subform on a subform. For a single level subform design, the subform reference is
    [Forms]![Main form name]![subform control name].[Form]![control name on subform]
    Last edited by Micron; 11-09-2017 at 10:07 PM. Reason: correction
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    mdavid is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2017
    Posts
    160
    Thanks for your help.
    I misspelled a textbox name - all gets a bit blurry at 3 am.
    This is what worked:
    Code:
    Forms![MempBercMainFrm2].[Form]![MempBercListBox].[Form]![lstbMempComplaints].RowSource = "SELECT " _
          & "ComplaintID, SpeciesID, Complaint, Preparation, Administration, " _
          & "ComplaintEdited, PreparationEdited, AdministrationEdited FROM MempComplaintTom " _
          & "WHERE SpeciesID = " & Forms![MempBercMainFrm2].[txtSpeciesID]
    Forms![MempBercMainFrm2].[Form]![MempBercListBox].[Form]![lstbMempComplaints].Requery
    I finally used Expression Builder - that someone here suggested - to reference the controls, a real time saver.
    Thanks
    David

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

Similar Threads

  1. Replies: 9
    Last Post: 06-15-2017, 04:28 PM
  2. runtime error 2465 'l1'
    By mike02 in forum Forms
    Replies: 5
    Last Post: 07-17-2013, 03:37 PM
  3. run time error 2465
    By karma in forum Access
    Replies: 3
    Last Post: 08-09-2012, 04:08 AM
  4. Run Time Error 2465
    By jo8701 in forum Programming
    Replies: 1
    Last Post: 02-08-2012, 12:01 PM
  5. Run-Time error '2465'
    By hawkins in forum Access
    Replies: 6
    Last Post: 08-19-2011, 04:07 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