automating reports

E

EASY

i have a number of reports running from perameter queries. The queries ask
for a date. so i have to enter the date in to each report query that takes
about 10 minutes. i would like to know a way to enter the date once and it be
applied to all the other reports and queries so that i can then print them. I
also need to email them out if there is a way of automating this aswell that
would be of a great help.

any ideas?
 
O

Ofer Cohen

The easies way will be to create a form with two Text Boxes where the user
will input the Start Date and End Date.
To refer to this text boexs to the report you can either add to the queries
Where DateFieldName Between Forms![FormName]![StartDateTextBox] And
Forms![FormName]![EndDateTextBox]

Or, when printing the report pass to it parameters using the where condition
of the Open Report Command line

Dim MyWhereCondition As String
MyWhereCondition = "[DateFieldName] Between " & _
Format(Me.[StartDateTextBox], "\#mm\/dd\/yyyy\#") & _
" And " & Format(Me.[EndDateTextBox], "\#mm\/dd\/yyyy\#")

Docmd.OpenReport "ReportName" , , , MyWhereCondition
 
F

fredg

i have a number of reports running from perameter queries. The queries ask
for a date. so i have to enter the date in to each report query that takes
about 10 minutes. i would like to know a way to enter the date once and it be
applied to all the other reports and queries so that i can then print them. I
also need to email them out if there is a way of automating this aswell that
would be of a great help.

any ideas?

Create an unbound form.

Add 2 unbound text controls.
Set their format to a valid date format.
Name them "StartDate" and "EndDate"

Add a Command Button to the form.
Code the button's click event:

Me.Visible = False

Name this form 'ParamForm'.

As criteria in the query date field of each query, write:
Between forms!ParamForm!StartDate and forms!ParamForm!EndDate

Next, code the first report's Open event:
DoCmd.OpenForm "ParamForm", , , , , acDialog

Code the last report's Close event:
DoCmd.Close acForm, "ParamForm"

When ready to run the report, open the first report.
The form will open and wait for the entry of the starting and ending
dates wanted.
Click the command button and the report will run.

Each additional report will show the same date range.

When the last report closes, it will close the form.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top