How do you open a report with different record sources?

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
 
D

Dorian

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".
 
D

Damon Heron

Private Sub Cmd20_Click()
DoCmd.OpenReport "rptMyReport", acViewPreview, "qryA"
End Sub

Damon
 
D

Damon Heron

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

Damon
 
K

Kevin C Niven

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
 

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