totn Access

MS Access 2003: Create a query that accepts Start date and End date as parameters

This MSAccess tutorial explains how to create a query that accepts a start date and an end date as parameters in Access 2003 (with screenshots and step-by-step instructions).

Question: In Microsoft Access 2003/XP/2000/97, I'm trying to run a query based on a date. When the query opens, I would like some type of window prompting for the user to enter a "start" date and an "end" date. How can I do this?

Answer: You can create a parameter query that prompts for both a "start" date and an "end" date.

To do this, first create your query.

Microsoft Access

Then enter your "start" date and "end" date parameters. Parameters should be enclosed in square brackets as follows:

>=[Start Date] And <=[End Date]

This will create a parameter called [Start Date] and a parameter called [End Date]. So that only those records from the Orders table will be returned where the OrderDate field is between these two dates.

Next, you probably want to ensure that the user enters a valid date in these two parameters. To do this, select Parameters under the Query menu.

Microsoft Access

When the Query Parameters window appears, enter the two parameters [Start Date] and [End Date], and select Date/Time as the data type. Click on the OK button.

Microsoft Access

Now, when you run the query, you will be prompted to enter the "start" date.

Microsoft Access

Then prompted to enter the "end" date.

Microsoft Access

Your query will then only return the records where the OrderDate is between these two values.