Report name as variable

Chris Morris

Registered User.
Local time
Today, 09:52
Joined
May 3, 2011
Messages
20
I have some code that will allow a user to pass to it the name of a report. The code will do various things to that report before presenting it for Preview, opening in Word etc.

At one point in the code I would like to refer to some control or property of the report. If I was to include this directly for one report, I might type:

Reports!Annual_Budget_Report.Recordsource = xyz

But instead of a specifc report, it would be the report as a variable (srReport_Name). However, if I type:

Reports!stReport_Name.Recordsource

The code complains, rightly, that there isn't a report called stReport_Name. The stReport_Name variable is currently set as String. I *think* the answer might lie in the variable type, but I'm still struggling.
 
Hi chris,

Example :

Code:
Reports(srReport_Name).Caption = "TESTING REPORT"

success

Contractor
 
Instead of:
Reports!stReport_Name.Recordsource

try Reports!" & stReport_Name & ".Recordsource

David
 
Hi David, I tried something similar without success, but thanks.

Thank you Contractor - that worked a treat.

Chris
 

Users who are viewing this thread

Back
Top Bottom