Assigning a Query as Report Record Source

  • Thread starter Thread starter Guest
  • Start date Start date
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.
 
Have you tried using

"MyQuery"

(including the quotes)?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
Back
Top