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.
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.
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.
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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.