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

Need Help Creating Search Form

Status
Not open for further replies.

NewComer

Technical User
Joined
Apr 26, 2001
Messages
35
Location
US
I'm creating a search form. So far I've created a subform and placed it on the main form. What I want to do is for the user to be able to type in what they are searching for in a text box on the main form and as they begin to type the subform will display everything that contains those characters entered and as they continue inputting, the search is narrowed. ex: the user is looking for transmission, they enter "tr" and everything in the search field that contains "tr" shows in the subform. As the user continues to enter the word transmission the search is narrowed.

I'm new to VBA, so you'll have to be specific. Thanks in advance for your help!!!
 
1 Create a query sorting all the options.
2 use the query to load teh list box on your subform.
done
 
The query for your subform will need this in the criteria for the field you are searching:

Like "*" & [Forms]![formName]![searchfieldName] & "*"

You'll have to requery the subform with :
Me![SubformName].Requery

It sounds like you'll want to put that code in the OnKeyPress event of the searchfield. This might be a little cumbersome if your recordset is large, or out on the network where data transfer is slow.
The other option is to use a "Find duplicate" query as the source of your search field, with your search field being a combo box.
 
Well that code doesn't work in the onKeyPress event. Looks like its a little more complicated for each keystroke.
Try it the other way and see if you like it.
 
Oh Pardoooon. It works fine in the OnChange event (and probably others), but you have to specify in the criteria [searchfieldname].[text]
This returns the present actual value of the field. Otherwise it defaults to .value, which is the last stored (updated) value of the field.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top