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

Retrieval of records using a text box input

Status
Not open for further replies.

SRMiller

Technical User
Dec 30, 2002
1
0
0
US
I am using Access 2000. I have a text box and I want to type in part of a string and retireve all of the records that match that partial string. Currently I'm using a form with a text box in the form header. The form is set as Default View "Continuous Forms". I've also tried to enter the data into the text box and link it to a subform whose record source was a query linked to the text box.
In other words. Here is data in the address field of my table.

Example:
1234 Main Street
Moller Plaza
4567 Harris Street
Boyd Shopping Center
3707 Harris Avenue
Fuller Place and Harris Street Improvement
Appleberry Business Center

"Harris" is entered into the text box - and the results would be:

4567 Harris Street
3707 Harris Avenue
Fuller Place and Harris Street Improvement

Thank you for help!
 
Check out Like in Help. I found the following in Access97.

Examples of expressions that use part of a field's value as criteria

Field Expression Displays
ShipName Like "S*" Orders shipped to customers
whose names start with the
letter S.

ShipName Like "*Imports" Orders shipped to customers
whose names end with the
word "Imports".

ShipName Like "[A-D]*" Orders shipped to customers
whose names start with A thru D.

ShipName Like "*ar*" Orders shipped to customers
whose names include the letter
sequence "ar".

ShipName Like "Mas Dewe?" Orders shipped to the customer
with "Mas" as the first part of
its name and a 5-letter second
name in which the first 4
letters are "Dewe" and the last
letter is unknown.

This example uses the Like operator to compare a string to a pattern.

Dim MyCheck
MyCheck = "aBBBa" Like "a*a" ' Returns True.
MyCheck = "F" Like "[A-Z]" ' Returns True.
MyCheck = "F" Like "[!A-Z]" ' Returns False.
MyCheck = "a2a" Like "a#a" ' Returns True.
MyCheck = "aM5b" Like "a[L-P]#[!c-e]" ' Returns True.
MyCheck = "BAT123khg" Like "B?T*" ' Returns True.
MyCheck = "CAT123khg" Like "B?T*" ' Returns False.

Good LucK!
 
Racer, I think you missed the jist of the topic. Anyways SR, add a button next to your textbox that will kick off the following on the click event:

Private Sub Command10_Click()
Me.Filter = "[Value] LIKE '*" & Me.Value & "*'"
Me.FilterOn = True
End Sub


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top