how to change report parameters in vba with out having to open the report

thydzik

Registered User.
Local time
Today, 20:29
Joined
Jun 17, 2006
Messages
27
i have run into the problem where I want to change parameters of a report in vba but it states I need to open the report first, which is no good.

at the moment I am just wanting to do the following

Dim r As Report
Set r = Reports("myReport")

but this only works when the report is open, is there a way to do this without opening the report.

i am actaully wanting to change the RecordSource parameter eventually, in vba without having to open the report.

thanks
 
Use a query for the report reord source; then dynamically change/modify the query prior to opeing the report.
 
thanks for the reply, might have to do that.
I also thought of using visible = false after opening a report.

pity you have to have the report opened
 
The report needs to be open for you to modify it. You could open it in design view, make the change, save it, and close it but I do not recommend this method. Plus, it will not work in a shared database. The best solution is to add code to the report's Open event to pick up the name of the RecordSource query or the actual SQL string. For example:

Me.RecordSource = Forms!someform!somefield
 

Users who are viewing this thread

Back
Top Bottom