Results 1 to 4 of 4
  1. #1
    4 Star Lounger
    Join Date
    Feb 2002
    Posts
    537
    Thanks
    0
    Thanked 0 Times in 0 Posts

    find in list box (Access 2000)

    I have a list box called ListCustomers and i have a control on the form called CmdFind. I want to find a customer in the list box by clicking the control and entering its number.However i get the message that Acces does not recognize the string strCustomerId. Can you help mein finding my error
    in the following command?


    Private Sub CmdFind_Click()
    Dim strCustomerID As String
    Dim strBookmark As String
    strCustomerID = InputBox("Please enter Customer number ")
    If strCustomerID = "" Then
    Exit Sub
    End If
    Me.RecordsetClone.FindFirst "strCustomerID = " & Me![list]
    If Me.RecordsetClone.NoMatch Then
    MsgBox "CustomerID " & strCustomerID & " Not Found!!"
    Me.Bookmark = strBookmark
    Else
    Me.Bookmark = Me.RecordsetClone.Bookmark
    End If
    End Sub

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: find in list box (Access 2000)

    If your customerID is a string and the items in the listbox are also strings then you have to add quotes in the FindFirst criteria:
    <pre>Me.RecordsetClone.FindFirst "strCustomerID = '" & Me![list] & "'"</pre>

    Francois

  3. #3
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: find in list box (Access 2000)

    Second thought:
    You Dim strCustomerID as string.
    You don't need that.
    In the line Me.RecordsetClone.FindFirst "strCustomerID = " & Me![list]
    with or without quotes, strCustomerID has to be a field of the recordset of the form containing your customerID.
    If that field is numeric, the items of the listbox must be also numeric and don't use the quotes.
    Francois

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

    Re: find in list box (Access 2000)

    Is this a bound listbox? Are you trying to move to the first record in the recordset that has that customerID in it? If so, you're going at it backwards. What you want to say is "

    Me.RecordsetClone.FindFirst "[CustomerID]=" & strCustomerID

    If you're trying to do something else, please expalin what it is. You can't use FindFirst on the listbox itself.
    Charlotte

Posting Permissions

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