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

Form Code With String Matching 1

Status
Not open for further replies.

StayAtHomeMom

Technical User
Sep 6, 2003
41
US
I need help with the code behind a form, more specifically on an After Update event. Basically, I want a form that has a textbox that I can enter a simple string. I then want the code to create a list of items (in a subform? in a list box? I don’t know) that satisfy the criteria based on the simple string I entered, i.e.

Select CatNo from MasterCatalogNoList where CatNo like “*” & [TextBoxEntry] & “*”

MasterCatalogNoList is a table in my database. The form would look something like this:

---------------------------------------------------------
Enter Catalog Number:
356



Matching CatNo Results:
89356PP
9093356U
YT356WQQ
356NNN
etc
----------------------------------------------------------
Thank you in advance for any guidance you can offer!
 
Create a ListBox, say lbCatNo, with a RowSourceProperty set to Table/Query.
In the AfterUpdate event procedure of TextBoxEntry add the following code:
lbCatNo.RowSource = "SELECT CatNo FROM MasterCatalogNoList WHERE CatNo Like '*" & TextBoxEntry & "*'"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PHV,

THANK YOU THANK YOU THANK YOU!! It works! It's amazing sometimes how we make simple things so darn complex. Thanks for your quick response. It saved my sanity.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top