Results 1 to 6 of 6
  1. #1
    Lounger
    Join Date
    Apr 2001
    Location
    Rockvale, Tennessee, USA
    Posts
    42
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Find Record (Access 2000)

    How can I use a ListBox.Value as criteria for DoCmd.FindRecord?

  2. #2
    Star Lounger
    Join Date
    Dec 2001
    Location
    Birmingham, Alabama USA
    Posts
    95
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Find Record (Access 2000)

    One way to do this is to use the BuildCriteria() Function that is in Access. Here is an example:

    Private Sub cboYourComboName_AfterUpdate()
    On Error GoTo ErrorHandler

    If Not IsNull(cboYourComboName) Then
    Me.RecordsetClone.FindFirst BuildCriteria("NameOfFieldInTable", dbText, cboYourComboName)
    Me.Bookmark = Me.RecordsetClone.Bookmark
    cboYourComboName = Null
    Else
    MsgBox "You Must Choose a Value from the ComboBox.", vbOKOnly, " No Item Selected ...."
    End If

    ExitHere:
    Exit Sub

    ErrorHandler:
    MsgBox Err.Description
    Resume ExitHere
    End Sub

    You can find more information on the use of this function in Access Help files.

    HTH
    RDH
    Ricky Hicks
    Microsoft MVP
    Birmingham, Alabama USA

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

    Re: Find Record (Access 2000)

    One caveat on BuildCriteria is that it only handles a single field at a time. If you want two different criteria (i.e., Field1 = "OK" And Field2 > 3), you'll have to run BuildCriteria twice and join the results. I always forget about the function because by the time you type in all the pieces, you might as well have created the criteria string by hand. <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>
    Charlotte

  4. #4
    Star Lounger
    Join Date
    Dec 2001
    Location
    Birmingham, Alabama USA
    Posts
    95
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Find Record (Access 2000)

    You are absolutely right .....
    I just thought I'd mention it due to many people not knowing that this function exists.

    Happy Holidays,
    RDH
    Ricky Hicks
    Microsoft MVP
    Birmingham, Alabama USA

  5. #5
    Lounger
    Join Date
    Apr 2001
    Location
    Rockvale, Tennessee, USA
    Posts
    42
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Find Record (Access 2000)

    Works Great, Thanks and Merry Christmas

  6. #6
    Star Lounger
    Join Date
    Dec 2001
    Location
    Birmingham, Alabama USA
    Posts
    95
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Find Record (Access 2000)

    Great .... You are Welcome .... <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

    Make sure you read Charlotte's note about the limations of using this function.

    Happy Holidays,
    RDH
    Ricky Hicks
    Microsoft MVP
    Birmingham, Alabama USA

Posting Permissions

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