Set the Source of the Report at Runtime

S

Samuel

Hi

I wonder how can I set the source of the report at runtime so when I call
the report the correct query will be called

Thank you,
Samuel
 
R

Rick Brandt

Samuel said:
Hi

I wonder how can I set the source of the report at runtime so when I
call the report the correct query will be called

That would usually be done in the Open event of the report. That code would
examine *something* and from that decide what the RecordSource should be. The
something could be controls on an open form, a global variable, values in a
table, etc.. The key line of code would be...

Me.RecordSource = "some string"
 
D

Douglas J. Steele

Assuming the report is open, you can use

Reports!NameOfReport!RecordSource = "NameOfQuery"

Alternatively, in the Open event of the report, you can use:

Me.RecordSource = "NameOfQuery"
 

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