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!

Need help on Macro 1

Status
Not open for further replies.

juli5e

Technical User
Apr 26, 2002
10
0
0
US
If I have generated a query successfully and would like to create a macro to automatically pull the query and give me a form format to input my criteria before running the query. How would I do this? Thank you in advance.
 
Let me make sure that I understand. You want to enter values in a form and use those values as criteria for your query.

Eric
 
Yes. My report is an inventory report that consists of all warehouse location and I was able to do that. As you know, at the query level, I can input a warehouse location and pull the inventory info. from there. I would like to perform a macro that would give me a form so I can input my selection and run. Your help is greatly appreciated.
 
Create a blank form.
Add a text box

In the properties of the text box, on the "Other" tab give it an appropriate name. For example: Where you would enter the Warehouse Location, name the text box txtWhseLoc.

Place a CommandButton on the form with this code behind it.
DoCmd.OpenQuery "YourQueryNameGoesHere[/color blue]"

Save the form and name it frmQueryParam
Open your query in design view. In the criteria for Inventory Id add this:
Like "*" & forms!frmQueryParam!txtWhseLoc& "*"

Save the query.

Go back to your form. Change the view to form view. Enter a warehouse ID in the text box. Click the button.

Your query should open showing the info for the Warehouse ID that you entered.

HTH,
Eric
 
Eric,
Did exactly what you had instructed and when I click on the button, it would give all warehouse locations. Just to clarify things, the "unbound" text box, in the "other" tab, I should label it txtWhseLoc. In the command button, since I am using Access 2000 still, the button wizard automatically pops up and I choose "run query". I copied the command that you had given:
Like "*" & forms!frmQueryParam!txtWhseLoc& "*"

When I attempt to run the form and input the warehouse location in the text box and hit the command button. It ran the query but gave me all locations. Please advise.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top