Can I change report source at docmd.openreport?

S

SF

Hi,

I have a report design to print data on cheque. I have two options: print
all and print for selected item. I have created the two source queries but
wondwer if I can change to Record Source of the report when executing the
docmd.openreport "rptCheque"

Would appreciate any advice here.

Regards

SF
 
D

Duane Hookom

I would not attempt to change the RecordSource if the fields are the same
and only the filter of the records changes. Consider adding a "where" clause
to your DoCmd.OpenReport....

Dim strWhere as String
strWhere = "1=1 "
If Me.chkPrintSelected = True Then
strWhere = strWhere & " AND [CheckID] = " & Me.txtCheckID
End If
DoCmd.OpenReport "rptCheque", acPreview, , strWhere

This all depends on your "selected item" field name and data type.
 

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