Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Finding a record (Access 97 SR2)

    I know of the following code for filtering for a record, which filters the field LEA for the entry made in the unbound combo box "LEA Filter":

    DoCmd.ApplyFilter , "[LEA]= forms![frmLEAUpdates]![LEA Filter]"

    However, I need to search and find a record without filtering and have been unable to work out how to use commands such as Gotorecord (think the brain is going a bit slow this afternoon!).

    Any help would be much appreciated.

  2. #2
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Finding a record (Access 97 SR2)

    A bit more complex than the filter then!

    That worked like a treat, thanks very much Charlotte.
    I'll have to look it up in a book to make sure I understand exactly how it works.

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

    Re: Finding a record (Access 97 SR2)

    Since you're using Access 97, that means DAO. Here's a typical DAO routine I used in Access 97 for finding the record specified in an unbound combobox:

    <pre>Private Sub cboCompany_AfterUpdate()
    Dim rst As DAO.Recordset
    Set rst = Me.RecordsetClone
    With rst

    <font color=448800>'if a there are records in the recordset </font color=448800>
    If Not .EOF Then

    <font color=448800>'find the record that matches the combobox</font color=448800>
    .FindFirst "[CustomerID]='" & [cboCompany] & "'"

    <font color=448800>'if Not .NoMatch means there was a match</font color=448800>
    If Not .NoMatch Then

    <font color=448800>'set the form's bookmark to the recordset's bookmark</font color=448800>
    Me.Bookmark = .Bookmark
    End If <font color=448800>'Not .NoMatch </font color=448800>
    End If <font color=448800> 'Not .EOF </font color=448800>
    End With <font color=448800>'rst </font color=448800>
    Set rst = Nothing

    <font color=448800>'set the focus to the first control</font color=448800>
    Me!CustomerID.SetFocus
    End Sub <font color=448800>'cboCompany_AfterUpdate() </font color=448800></pre>

    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
  •