- Create a table with three columns - ID, Firstname, and Surname.
- Enter a some test data into the table. Between five and ten random names should do for this purpose. You might like to give some of the records the same surname.
- Create a new query by clicking the QUERY DESIGN icon. This is located in the OTHERS group of the Access CREATE ribbon.
- Once the Query Design Window opens, select the Table you just created from the SHOW TABLE dialogue box.
- Then select the three fields contained in this table. The quickest way of doing this is to double click each field name listed in the table box in the upper section of the screen. These will then appear as field headings in the QUERY DESIGN GRID.
- The last stage is to enter the user prompt in the criteria row of the Surname column. As you may remember, this has to be enclosed within square brackets. Our prompt is going to be [Enter Surname].
|Figure 1: A Parameter Query created in the Query Design Grid.|
Then when you run the query you get this message:
|Figure 2: Enter Parameter Value Dialogue Box.|
Another great thing about Parameter Queries that you might like to try, is using them as the record source for a form. When the form is loaded the query runs asking you to enter a parameter value as before. This time, however, once you click OK, the form opens displaying a set of records based on the value entered.