Set the Source of the Report at Runtime

  • Thread starter Thread starter Samuel
  • Start date Start date
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
 
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"
 
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"
 
Back
Top