Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting "RecordSource" Property In Reports

Status
Not open for further replies.

hoppergs

IS-IT--Management
Feb 24, 2003
39
GB
I'm trying to do the above in VBA code. I have a report that has the RecordSource property set to a certain query name, however on occasions I want this report to run and base it's results on other queries.

I've used the [Filter] part of the "Docmd.OpenReport" method to do this but it doesn't seem to be working properly. I've also looked at using RecordSource property in code before using the "Docmd.OpenReport" line, but it won't let me do this because the report is not open.

Does anyone know what the best way of doing this is?

Thanks

Graham
 
One method...

Create a global variable when you want the report to use a different recordsource populate the global with the recordsource name.

Then in the open event of the report evaluate the global if it is not null then use change the recordsource of the report. It will change now because the report is open.

Just make sure you clear the global when the report is closed or unloaded.

ssecca
 
You could add code to the OnOpen event of your report to set the report's RecordSource to a different query if some condition is met.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top