I have a report based on a query and need to be "asked" what date to use for
the data selection. What is the easiest way to do that?
Why do you need to be asked?
Here is a better solution to select a range of records based upon a
date.
You'll need to use a form to do this.
First, create a query that will display the fields you wish to show in
the report.
Second, create a report, using the query as it's record source, that
shows the data you wish to display for ALL records.
Next, make a new unbound form.
Add 2 unbound text controls to the form.
Set their Format property to any valid date format.
Name one "StartDate".
Name the other "EndDate".
Add a command button to the form.
Code the button's Click event:
Me.Visible = False
Name this form "ParamForm"
Go back to the query. As Criteria on the DateField, write:
Between forms!ParamForm!StartDate and forms!ParamForm!EndDate
Code the Report's Open Event:
DoCmd.OpenForm "ParamForm" , , , , , acDialog
Code the Report's Close event: **
DoCmd.Close acForm, "ParamForm"
Run the Report.
The report will open the form.
Enter the starting and ending dates.
Click the command button.
The Report will display just those records selected.
When the Report closes it will close the form.
** If you have additional reports to run, using the same date
parameters, as long as this form remains open, you can run the other
reports and you will not be prompted for the date range. So... don't
close the form until the last report is run.