Assigning a Query as Report Record Source

G

Guest

I've almost got the answer to my question by reading previous posts, but
still need a little help. I have learned that the best way to assign a
record source,on the fly, for reports is with the report's Open Event with
code such as below:

me.RecordSource=SQL

However, I'm not sure how to address the query. For example, if the query
name is "MyQuery", how should the 'Me.RecordSource' be written?

What I am doing is using one report with several queries to produce (from my
the end user perspective) several report outputs. The user clicks a button
backed up with code such as:

OpenArgs=1
DoCmd.OpenReport stReport, acViewPreview, , , acWindowNormal, OpenArgs


The OpenArgs value is passed to the report and used in the Open Event with
code such as:

Select Case OpenArgs
Case 1
Me.RecordSource=Query1
Case 2
Me.RecordSource=Query2
End Select

Appreciate your help.
 
J

Jeff Boyce

Have you tried using

"MyQuery"

(including the quotes)?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 

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