Passing a Memory Variable from a Form to a Reprt in Access 2007

5 pts.
Tags:
Variables
In Microsoft Access, I am using a Form to set up parameters and run reports from a single database. One of the parameters is a report title. Within the Form, I have set up VBA code for running the reports. I am using a memory variable (strReportName) to store the title for each report, rather than having to create a new report object each time I want to use a new title. Within the Form, at the very top of the code window under "Option Compare Database", I am using the following code to declare strReportName: Dim strReportName As String Within the Report, I have set up a text box object to store the title. Within the properties for this text box, under data, I have set the control source to read: =[strReportName] My problem is this: the title being stored in strReportName is not making it's way from the Form to the Report, and thus the Report is not printing out any titles. How do I solve this? Sincerely, Steve Demogenes

Software/Hardware used:
Microsoft Access 2007
ASKED: July 31, 2011  4:50 AM
UPDATED: March 31, 2012  7:34 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

The reason it doesn’t work is that the variables of a form are not available to a report. If you make a hidden field on the form (for example MyFormReportTitle) and set the title in that field before you run that report, you can reference it in the report. So in the on open event of the report, you could enter the following code: me![ReportTitle] = Forms![MyFormName]![MyFormReportTitle]

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following