Results 1 to 10 of 10
  1. #1
    lycialive is offline Novice
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Posts
    7

    Getting error code 3070 for combo box

    Error 3070 the microsoft office access database engine does not recognize ID as a valid field name or expression. I get this error, but I've used the same code for other databases. Can anyone help? It's for a simple combo box:

    Private Sub Combo11_AfterUpdate()
    ' Find the record that matches the control.
    Dim rs As Object

    Set rs = Me.Recordset.Clone


    rs.FindFirst "[ID] = " & Str(Nz(Me![Combo11], 0))
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark
    End Sub

    Thanks!

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    ID is autonumber field? Why are you using the Str function?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    lycialive is offline Novice
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Posts
    7
    I don't know vb at all, the code was given to me. I've just been using it, and it works okay for things in the past.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Is ID an autonumber field? Why don't you try without the Str function?

    Assuming ID is actually a field in the form's RecordSource.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    lycialive is offline Novice
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Posts
    7
    Quote Originally Posted by June7 View Post
    Is ID an autonumber field? Why don't you try without the Str function?

    Assuming ID is actually a field in the form's RecordSource.
    I'll try that, thanks!

  6. #6
    lycialive is offline Novice
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Posts
    7
    Yes, the ID appears to be an autonumber field. But using the code without the str doesn't work. I just tried it now.

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Guess will have to provide db for analysis. Follow instructions at bottom of my post. Identify objects involved in issue.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Don't have time to test this, but with the code

    rs.FindFirst "[ID] = " & Str(Nz(Me![Combo11], 0))

    you're forcing Me![Combo11] to be a String, but your syntax in that line is only correct for a Number! I'd try replacing it with the syntax for Text

    rs.FindFirst "[ID] = '" & Str(Nz(Me![Combo11], 0)) & "'"

    and see what happens.

    Linq ;0)>

  9. #9
    lycialive is offline Novice
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Posts
    7
    Thanks for all the replies. I just re-built it with Access 2003 using the same coding and everything works perfect.

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Don't know why the code works with 2003 but think just realized the problem with code in 2007/2010. It is the dot (.) in Recordset.Clone.

    Don't really need to declare rs Object. Alternative code:

    With Me.RecordsetClone
    .FindFirst "[ID] = " & Nz(Me.Combo11, 0)
    If Not .EOF Then Me.Bookmark = .Bookmark
    End With
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 6
    Last Post: 11-18-2012, 05:06 PM
  2. Replies: 1
    Last Post: 08-09-2012, 04:19 PM
  3. Error 3070 When Navigating to a Record
    By Epidural in forum Access
    Replies: 1
    Last Post: 05-10-2012, 09:14 AM
  4. filtering of combo box / vba code
    By Kotoca in forum Programming
    Replies: 2
    Last Post: 02-08-2012, 08:15 AM
  5. Error in Code
    By Lockrin in forum Programming
    Replies: 3
    Last Post: 02-25-2010, 03:27 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