Set the RecordSource of a report from a command button

J

Jason Farrugia

Access I have a standard report that I would like to use for a number of queries. I am trying to figure out how I can use a command button to change the RecordSource to one of the other queries to generate the report.

Any assistance would be much appreciated
 
R

Rick Brandt

Jason Farrugia said:
Access I have a standard report that I would like to use for a number of
queries. I am trying to figure out how I can use a command button to change the
RecordSource to one of the other queries to generate the report.
Any assistance would be much appreciated

The best place to change the RecordSource of a Report is in its Open event. You
can have the button set the value of a hidden control on a form or use a global
variable and then in the Report's Open event have code similar to...

Select Case GlblVar
Case "This Value"
Me.RecordSource = "ThisQuery"
Case "ThatValue"
Me.RecordSource = "ThatQuery"
etc..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top