Pass value to multiple reports

D

Duck

I have a series of reports that need to print at the same time, each
of which has a field that displays the date for which the report is
intended. All the reports need to have the same date, but that date
needs to be able to be chosen by the user. The problem is that I
can't use the OpenArgs capability because this particular system is
running MS Office 2000. On my systems with Access 2003 I used the
following code:

Public Sub OpenMealLists()
Dim intAns As Integer
Dim strAnsDate As String
Dim dteDate As Date


intAns = MsgBox("Is This Dining List For Today ?", 36, "Date of
Report")
If intAns = 7 Then
strAnsDate = InputBox("Please Enter Date For This Dining
List")
dteDate = CDate(strAnsDate)
Else
strAnsDate = Date
End If
Debug.Print dteDate

DoCmd.OpenReport "rptMealListB", , , , , strAnsDate
DoCmd.OpenReport "rptMealListL", , , , , strAnsDate
DoCmd.OpenReport "rptMealListD", , , , , strAnsDate
End Sub


How can I ascertain the date to pass once, and pass it to all three
reports without having to query the user three times for the date?
 
J

John W. Vinson

I have a series of reports that need to print at the same time, each
of which has a field that displays the date for which the report is
intended. All the reports need to have the same date, but that date
needs to be able to be chosen by the user. The problem is that I
can't use the OpenArgs capability because this particular system is
running MS Office 2000. On my systems with Access 2003 I used the
following code:

Public Sub OpenMealLists()
Dim intAns As Integer
Dim strAnsDate As String
Dim dteDate As Date


intAns = MsgBox("Is This Dining List For Today ?", 36, "Date of
Report")
If intAns = 7 Then
strAnsDate = InputBox("Please Enter Date For This Dining
List")
dteDate = CDate(strAnsDate)
Else
strAnsDate = Date
End If
Debug.Print dteDate

DoCmd.OpenReport "rptMealListB", , , , , strAnsDate
DoCmd.OpenReport "rptMealListL", , , , , strAnsDate
DoCmd.OpenReport "rptMealListD", , , , , strAnsDate
End Sub


How can I ascertain the date to pass once, and pass it to all three
reports without having to query the user three times for the date?

I'd suggest having a textbox txtDate on your Form (rather than using an input
box); have it default to Date() if the user will ordinarily be getting today's
date. Base each report on a Query with a criterion

=[Forms]![YourFormName]![txtDate]

on the datefield.

John W. Vinson [MVP]
 
F

fredg

I have a series of reports that need to print at the same time, each
of which has a field that displays the date for which the report is
intended. All the reports need to have the same date, but that date
needs to be able to be chosen by the user. The problem is that I
can't use the OpenArgs capability because this particular system is
running MS Office 2000. On my systems with Access 2003 I used the
following code:

Public Sub OpenMealLists()
Dim intAns As Integer
Dim strAnsDate As String
Dim dteDate As Date

intAns = MsgBox("Is This Dining List For Today ?", 36, "Date of
Report")
If intAns = 7 Then
strAnsDate = InputBox("Please Enter Date For This Dining
List")
dteDate = CDate(strAnsDate)
Else
strAnsDate = Date
End If
Debug.Print dteDate

DoCmd.OpenReport "rptMealListB", , , , , strAnsDate
DoCmd.OpenReport "rptMealListL", , , , , strAnsDate
DoCmd.OpenReport "rptMealListD", , , , , strAnsDate
End Sub

How can I ascertain the date to pass once, and pass it to all three
reports without having to query the user three times for the date?

By using a form to enter the date in.
Set the Format of the control on the form to a valid date format.

In each query that is used as record source for each report, set the
criteria on the date field to
forms!FormName!ControlName

Then using a control on each report, refer to that control on the
form.
="For Sales on " & Format(Forms!FormName!ControlName,"mmmm d, yyyy")

The form must be open when each report is run.

You can close the form in the Close event of the last report to run.
 

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

Similar Threads


Top