using module variable in report (1 Viewer)

djpearce

Bamedele
Local time
Today, 07:10
Joined
May 12, 2004
Messages
27
Hi Helper,
I am using the docmd.openreport method to print 4 report from VBA. I have the date for the reports (all use the same date) in a variable. How do I pass that variable from VBA to either the query or the report form? This will prevent me from entering the same date 5 times (1 to fill the variable, and once for each of the 4 reports).
Thanks
Bamedele
 
Last edited:

KenHigg

Registered User
Local time
Today, 07:10
Joined
Jun 9, 2004
Messages
13,327
Are you entering the date ranges in text boxes on a form or is some code coming up with it?

kh
 

djpearce

Bamedele
Local time
Today, 07:10
Joined
May 12, 2004
Messages
27
I am using the inputbox function to input the date into a field (strPayDate).
 

KenHigg

Registered User
Local time
Today, 07:10
Joined
Jun 9, 2004
Messages
13,327
djpearce said:
I am using the inputbox function to input the date into a field (strPayDate).

Do you mean you are using it to place a value into a variable and now you want to use it (them) as parameters for you reports?

kh
 

djpearce

Bamedele
Local time
Today, 07:10
Joined
May 12, 2004
Messages
27
Yes. I input the value in the variable using InputBox(). Now I want to use that valua (a date) on the report header (eg "Pay Period Ending 9/30/04"). The Openreport is executed in the same procedure that has the variable.
 

djpearce

Bamedele
Local time
Today, 07:10
Joined
May 12, 2004
Messages
27
Thanks Rich. But I can't see what you want me to do with the line of code.
Here is an example of what I have
strPayDate is defined in the declaration section.

Public Sub ProcessWages()

' Get Pay Ending Date
strMsg = "Enter Pay Period Ending Date"
strPayDate = InputBox(Prompt:=strMsg, TITLE:="Wages File Name", XPos:=3000, YPos:=3000)

' Print Wages related reports
DoCmd.OpenReport "rptControlTotal", acViewPreview
DoCmd.OpenReport "rptCBRSBCPSS", acViewPreview
DoCmd.OpenReport "rptBCPSSDeduct", acViewPreview
DoCmd.OpenReport "rptBCPSSCBRS", acViewPreview
End Sub


I want to use the date entered in strpaydate in the report header for all 4 of the reports.
 
R

Rich

Guest
Use a popup form and textbox, it's much easier, or else create a PublicVariable and use something like



strMsg = "Enter Pay Period Ending Date"
strPayDate = InputBox(Prompt:=strMsg, TITLE:="Wages File Name", XPos:=3000, YPos:=3000)

MyVariable=strPayDate
 

Users who are viewing this thread

Top Bottom