Results 1 to 4 of 4
  1. #1
    Star Lounger
    Join Date
    Jan 2001
    Location
    Kansas, USA
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts

    combobox and FindFirst (Access2000)

    I'm using the following code to go to the selected record but it doesn't work. Since the field tnCMNum is a text field, do I have all my double quotes & single quotes right? Or is something else amiss?

    Private Sub cboCustNum_AfterUpdate()
    Dim rst As Recordset
    Set rst = Me.RecordsetClone
    rst.FindFirst "tblTaxNumbers!tnCMNum = ' " & Me![cboCustNum] & "'"
    If Not rst.NoMatch Then Me.Bookmark = rst.Bookmark
    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: combobox and FindFirst (Access2000)

    When you say it doesn't work, what do you mean? I can see one thing wrong with it--you shouldn't fully reference the field tnCMNum in your criteria string. You're looking for the value in the form's recordsetclone, so you use the field name in the clone and look for the selected value in that field.

    I'm assuming that you have the DAO reference turned on and the ADO reference turned off, because otherwise, you have other problems to deal with.
    Charlotte

  3. #3
    Star Lounger
    Join Date
    Jan 2001
    Location
    Kansas, USA
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: combobox and FindFirst (Access2000)

    Charlotte,
    What I meant was that it didn't go to any record. But I did some more research on the net and found another code example. This code works for me:

    If Not IsNull(Me.cboCustNum) Then
    With Me.RecordsetClone
    .FindFirst "[tnCMNum]=""" & Me.cboCustNum & """"
    If Not .NoMatch Then
    Me.Bookmark = .Bookmark
    End If
    End With
    End If

    Thanks!

  4. #4
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: combobox and FindFirst (Access2000)

    >>.FindFirst "[tnCMNum]=""" & Me.cboCustNum & """"<<

    Try to put in those extra quotes is always a problem, especially when trying to read it later. Use chr(34) instead, as in this:

    .FindFirst "[tnCMNum]=" & chr(34) & Me.cboCustNum & chr(34)
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •