30th Jan 1999

 

Introduction to Database Development: Part 5

More on Queries

 

Parameter Queries

Prompts

Using a Form

 

Back

 

Other Sections:

Tables

Forms

Queries (1)

Queries (2)

 

Parameter Queries

In the previous example a subset of records were selected by using the criteria: Between #01/01/70# And #31/12/72# in the DOB field. However, while this is a very useful technique there a likely to be many cases where a different range of dates are required; this would necessitate either setting up more very similar queries, which could be come confusing, or editing the existing query every time a different date criteria was required.

One way to avoid this problem is to prompt the user to enter the date criteria every time the query is run. For this we use a parameter query. The criteria is changed to: Between [1st date] And [2nd date].

ParamCriteria.gif (2321 bytes)

Prompting the User

This time when the  QryRunButton.jpg (910 bytes) the user is prompted to enter a value.

1stDate Parameter promptNote how the text between the square brackets is now the prompt for the user i.e. 1st date.

The date is entered in d/m/yy format.

 

 

When the OK button is clicked or the user presses the Enter key the second parameter value is requested.

2ndDate.jpg (11148 bytes)

When the second value is processed the result is a set of 4 record from the original 8 (see below).

ParamQryOutput.jpg (33681 bytes)

While the parameter query is an improvement on requiring the user to modify queries it none the less has many drawbacks when used like this. For example it can become confusing where several criteria are required, also if the user makes a mistake he/she cannot change a parameter value once the OK button has been clicked.

Using Forms with Parmeter Queries

A form can provide a User Interface to a parameter query.

ParamForm.jpg (42944 bytes)

 

 

Developer Links
(including Access)

Glossary

 

  itweb2.gif (1323 bytes)