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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Locate Record in Table

Status
Not open for further replies.

Dickx

Technical User
Aug 24, 2001
33
US
I want to be able to locate a specific record in a table by filtering the records using an input box on the form. If the complete description in the order field is 100073856, I need to be able to select the record by entering only 7385. The code I have constructed thus far works only if I enter the full description. How would I modify the criteria statement to get it to work ?

Private Sub LocateOrder_Click()
If Me.FilterOn Then
Me.FilterOn = False
LocateOrder.ForeColor = 0

Exit Sub
End If

Dim Answer As String
Answer = InputBox("Order:", "Filter By Item", Default)
If IsNull(Answer) Then
Exit Sub
End If

Dim criteria As String
criteria = "[Order] Like '" & Answer & " *'"
Me.Filter = criteria
Me.FilterOn = True
LocateOrder.ForeColor = 255
End Sub
 
How about:
criteria = "[Order] Like '*" & Answer & "*'"
 
Your suggestion worked fine.

Thank you

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top