How do you open a report with different record sources?

  • Thread starter Thread starter Kevin C Niven
  • Start date Start date
K

Kevin C Niven

I'd like two have two buttons on my form:

One that opens rptMyReport with record source qryA

and

One that opens rptMyReport with record source qryB

How do I do this?

Many thanks,
Kevin
 
You can pass the record source in the openargs parameter and load the report
property when the report loads.
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".
 
Private Sub Cmd20_Click()
DoCmd.OpenReport "rptMyReport", acViewPreview, "qryA"
End Sub

Damon
 
Oh and make the record source of the report = the table that the querys are
based on.

Damon
 
Thank you, Damon, for your response. I ended up doing something
somewhat different.

In the button's OnClick event, I put:

DoCmd.OpenReport "rptMyReport", acViewReport, "", "", acNormal

Then, in the report's OnOpen, I put:

If Forms!DataEntryMain!chkMyCheck Then
Me.RecordSource = "qryA"
Else
Me.RecordSource = "qryB"
End If

I did it this way because I specifically wanted to replace the record
source and not put a filter on top of a record source.

Best regards,
Kevin
 
Back
Top