Results 1 to 9 of 9
  1. #1
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727

    access database engine does not recognize


    All, using access 2010; I have a form with a combo box to filter a subform. I had it working fine but someone had access to the database and did something to itL Now the code will not work. I am getting an error: the microsoft access database engine does not recognize as a valid field name or expression.
    The master and child links are correct and I have not changed the following code:

    Code:
    Private Sub cboCustID_AfterUpdate()
     ' Find the record that matches the control.
        Dim rs As Object
        Set rs = Me.Recordset.Clone
        rs.FindFirst "[cust_id] = '" & Me![cboCustID] & "'"
        If Not rs.EOF Then Me.Bookmark = rs.Bookmark
    End Sub
    I also tried the following:

    Code:
    ' Find the record that matches the control.
    Me.Filter = "[cust_id] = " & Chr(34) & Me.cboCustID & Chr(34)
    Me.FilterOn = True
    My fault for not backing up but I didn't get too far into this project. Please some one help.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Sounds like the problem is here
    rs.FindFirst "[cust_id]

    Check to make sure that cust_id is the correct spelling for the field name. Look at the table and or query that the form is based on.

  3. #3
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727
    Thanks for replying. This is the first thing I checked in case someone changed the name. But I checked and it the name is cust_id in the sub-form.

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Then creating a recordsetclone of the Main form is not what you are after
    Set rs = Me.Recordset.Clone

    Maybe creating a recordsetclone of the subform will work
    Set rs = Me.NameOfSubControl.Form.RecordsetClone

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Just for the record:
    Me.Recordset.Clone is an ADODB method
    ...and...
    Me.RecordsetClone is a DAO property

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by RuralGuy View Post
    Just for the record:
    Me.Recordset.Clone is an ADODB method
    ...and...
    Me.RecordsetClone is a DAO property
    True, I forgot about that. And the methods behave differently too. Since it is all within the same DB, I recommend DAO and RecordsetClone

  7. #7
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727
    ok. Do I referenced the sub form first: Set rs = me.sfmForm.cust_id.form.recordsetClone ??

  8. #8
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727
    This didn't work.
    Code:
    Private Sub cboCustID_AfterUpdate()
     ' Find the record that matches the control.
        Dim rs As Object
       Set rs = Me.sfrmCust.Form.RecordsetClone
        rs.FindFirst "[cust_id] = '" & Me![cboCustID] & "'"
        If Not rs.EOF Then Me.Bookmark = rs.Bookmark
    End Sub
    What did I do wrong?

  9. #9
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Hi -

    You set rs to be a recordsetclone of the subform, but then you used me.bookmark = rs.bookmark, which tries to set the bookmark in the main form.

    try: If Not rs.EOF Then Me.sfrmCust.Form.Bookmark = rs.Bookmark

    to set the bookmark in the subform

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

Similar Threads

  1. Replies: 1
    Last Post: 04-24-2014, 03:49 AM
  2. Replies: 6
    Last Post: 11-12-2012, 11:01 PM
  3. Replies: 6
    Last Post: 10-30-2010, 08:42 AM
  4. Replies: 1
    Last Post: 03-02-2010, 03:01 AM
  5. Replies: 1
    Last Post: 07-21-2009, 03:01 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