Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need a FIND tool for VB6

Status
Not open for further replies.

MickJ

Programmer
Feb 20, 2002
21
US
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
 
Hi,

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 &quot;ID Number&quot;
DoCmd.FindRecord [num], acEntire, , acSearchAll, , acCurrent, True
DoCmd.Hourglass False
Forms![A: Establishment form].Visible = True
done = True
DoCmd.GoToControl &quot;Establishment Name&quot;
Forms![A: Establishment form]![ID Number].Enabled = False
End If
End If
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top