We use a parameter “Query” when we execute the same “Query”, but with different criteria. For example, we have a “Query” that gives us all orders for the product “Computers”. We would normally enter “Computers” in the criteria box for the “Products”. Now wish to repeat this “Query”, but for another product. So, we either create a separate “Query” for each product, or change the criteria box for each Product.
However, by making use of a parameter “Query” this is not necessary. Whenever you have a parameter “Query”, a dialogue window will appear in which to enter criteria. This may relate to both criteria of one field or several fields.
In this example I use the “Query” made in the previous lesson, and open it in “Design View”.
I add the field “Article” from the “Products” table to the grid.
In the “Criteria” of the “Article” column, in square brackets, I enter the text that I want to appear in the dialog window, when I run the “Query”.
For example, [type an article]
When you click on the “Run” button in the “Ribbon”, the dialog window asks you to type in an article.
The article that you type should naturally have orders, otherwise no records are displayed.
Remember to save this “Query” under an appropriate name, such as “Order Totals”.
Before I forget, we change our totals column to a currency. This makes things clearer. This time, we go back to the “Design View”:
Select the column totals in the grid (1) and click “Properties Window” (2).
In the “Properties window”, set the format as “Currency” (3).
This is better:
In the following example of a parameter “Query”, I use two values. We add the “Date” field to this “Query” from the “Orders” table because I want to display the orders between certain dates.
I also add the “Date” field to the grid. In the “Criteria” of the “Date” column, I now have to enter two options: A dialogue window with a start date, and a dialogue window with an end date.
So I type> begindate] And <[enddate]
If you prefer, sort in any order.
When I click the “Run” button in the “Ribbon”, I get a first dialogue window where I need to enter the begin date. When I click OK, I get the second dialog window where I need to enter an end date.
I click the OK button again, I get to see the result.
For your information:
If I [type an article] criteria in the “Item” column, “Access” would also ask me which item I want to see.
You've completed Lesson 28 START NEXT LESSON