Thanks you. I am not sure how to add the code to the click event or code
the main report close event. Please for detail instructions.
Thanks
:
On Tue, 24 Feb 2009 13:34:01 -0800, Christina wrote:
I have a report and a subreport run from queries which each require the
input of a beginning date and an ending date. I would like to be requested
to input the criteria once instead of twice.
Thanks
You will need a form for this.
Create a form. Add 2 unbound text controls.
Set their format property to a valid date format.
Name one control "StartDate'.
Name the other control "EndDate".
Add a command button to the form.
Code it's click event:
DoCmd.OpenReport "ReportName", acViewPreview
Me.Visible = False
Name this form "ParamForm".
As criteria for the main report query, and also for the sub-report
query, enter, on the Date field's criteria line:
Between Forms!ParamForm!StartDate and Forms!ParamForm!EndDate
Code the Main Report's Close event:
DoCmd.Close acForm, "ParamForm"
Then when you are ready to run the report, open the form.
Enter the starting and ending dates wanted.
Click the command button.
The report and it's sub report will run.
When the report closes, it will also close the form.
For the Form, select the Command Button.
Display the button's property sheet.
Click on the Event tab.
Click on the event line you wish to code, i.e. the Click event.
Write
[Event Procedure]
on that line.
Then 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 your code for the command button.
DoCmd.OpenReport "ReportName", acViewPreview
Me.Visible = False
For the Report, display the Report's property sheet.
Click on the Close evnet line and follow the same instructions as for
the Form Command button.
Write the code:
DoCmd.Close acForm, "ParamForm"