Opening a datasheet form with a specific query criteria

Bullman2000_uk

Registered User.
Local time
Today, 18:49
Joined
Jun 6, 2007
Messages
17
I have a supplier search query set-up where you can enter part of the supplier name and it will return all matches. This criteria is set-up as

Like "*"&[Enter Supplier Name]&"*"

I have on a supplier search form a text box (me.text2) where you enter in the part of the supplier name and click on a button to open the datasheet form returning all the entries. I want it to feed that field into the [Enter Supplier Name] section of the query to complete the search. Can anyone advise me of the VBA code that I will need to enter in for the button, I have tried several things but can't get it to work.

Can you help

Cheers
 
Instead of VBA, you can put this right into your query by changing the line:

Like "*"&[Enter Supplier Name]&"*"

To:

Like "*"& Forms![FormNAME]![Text2] &"*"

I would suggest using something a bit more meaningful than "Text2" as the name of the textbox, something like txtSupplier or txtSupplierSearch.

When the query is run from the form, the query will automatically look for the value in that field. So that form has to be opened for the query to run (which doesn't sound like a problem, since your button is on the form, so it has to be open.)
 

Users who are viewing this thread

Back
Top Bottom