I'm looking for a "Find" tool, hopefully similar to the one used in MS Access. I need to search a database to locate a particular record based on the contents of various fields, e.g. Last Name, Stock # etc. Thanks
Here is a bit of code I wrote to find a record based on its ID number. The user clicks on a button called "Find record" on the form and a small form appears in which they enter the id number they want. Upon pressing enter the following procedure is called. Text1 is the text box into which the id number is entered. "Establishment Form" is the name of the form being searched and "Id number" is the field being searched.
Hope this is of some help, let me know if it works.
RFletch
Private Sub findrec()
Dim num As Integer
done = False
If isloaded("A: Establishment Form" Then
If Not IsNull(Text1.Value) And (Text1.Value < 32767) Then
num = Text1.Value
Me.Visible = False
DoCmd.Hourglass True
Forms![A: Establishment form].SetFocus
Forms![A: Establishment form]![ID Number].Enabled = True
DoCmd.GoToControl "ID Number"
DoCmd.FindRecord [num], acEntire, , acSearchAll, , acCurrent, True
DoCmd.Hourglass False
Forms![A: Establishment form].Visible = True
done = True
DoCmd.GoToControl "Establishment Name"
Forms![A: Establishment form]![ID Number].Enabled = False
End If
End If
End Sub
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.