I have several reports all of which now need to include records from a user
specified date range. The reports are all run from a menu selection.
Do I need to set up a different form as the front end for each report to
collect the date criteria or is there a way of selecting the report and
storing the report name so that the correct report runs after the date
criteria is input. I have a command button on the form to open the report but
can't see how to specify which report automatically. I'm not a great VB user
so all simple help much appreciated!
Sheila
You can use just one form to do this.
1) It seems from your question, that the reports are NOT run, one
after the other in sequence, but randomly.
First, create a query for each report, 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.
Let's assume it a starting and ending date range that you need to use
as criteria on each report..
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 each Report's Open Event:
DoCmd.OpenForm "ParamForm" , , , , , acDialog
Code each 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.
2) If the reports are always run together, in sequence, then just code
the first report's Open event to open the ParamForm, and code just the
last report's Close event to close the ParamForm.
The ParamForm will then remain open for all of the reports, and you
will not be prompted for the start or end dates. When the final report
is done, it will close the ParamForm.