Dynamic change for record source.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a report that can use 2 separate queries when executed. The determination of which query to use as the record source is contingent on how the user accesses the report. I would like to be able to change the record source on the report dynamically.

I have set up a test form with 2 buttons (simulating the calls to the report) and would like to be able to have each button change the record source and open the report at the same time.

How can this be done in Access 2003?

Thanks,

Larry
 
lmcgahee said:
I have a report that can use 2 separate queries when executed. The determination of which query to use as the record source is contingent on how the user accesses the report. I would like to be able to change the record source on the report dynamically.

I have set up a test form with 2 buttons (simulating the calls to the report) and would like to be able to have each button change the record source and open the report at the same time.

How can this be done in Access 2003?


You need to use the report's Open event to change the
report's RecordSource property.

There are lots of way to tell the report which query ro use.
The cleanest way is to use the OpenArgs argument on the
OpenReport method. This way, all you have to do is ,ale a
slight change to the code behind each button:

DoCmd.OpenReport stDoc, . . . , _
OpenArgs:= "queryA"

And add a little code to the report's Open event:

If Not IsNull(Me.OpenArgs) Then
Me.RecordSource = Me.OpenArgs
End If
 
Thanks Marshall.....I saw your name out there a lot and wasn't surprised that you had the answer. That process worked great.

Thanks,

Larry
 
Back
Top