I hae a query set up to sort all my data into nice little reports. The only
problem is a month from now I don't want to have to print everything just to
get yesterdays report. I would like a query that says only show the records
for date X through Y, and I would like to use a form to enter the dates, run
the query then show the report for printing.
Thanks
David
Create an unbound form.
Add 2 unbound text controls
Name one control 'StartDate'.
Name the other control 'EndDate'
Set their format property to any valid date format.
Add a Command Button to the form.
Code the button's click event as follows:
(Note: To write the code, in Form Design View select the command
button. Display the button's property sheet.
Click on the Event tab.
On the On Click line, write:
[Event Procedure]
Click on the little button with the 3 dots that appears on that line.
When the code window opens, the cursor will be flashing between 2
already existing lines of code.
Between those lines, write the following code.)
Me.Visible = False
Close the Code window.
Name this form 'ParamForm'.
In the Query that is the Report's Record Source [DateField] criteria
line write:
Between forms!ParamForm!StartDate and forms!ParamForm!EndDate
Next, code the Report's Open event:
(Using the same method as described above)
DoCmd.OpenForm "ParamForm", , , , , acDialog
Code the report's Close event:
DoCmd.Close acForm, "ParamForm"
When ready to run the report, open the report.
The form will open and wait for the entry of the starting and ending
dates.
Click the command button and then report will run.
When the report closes, it will close the form.