Can I change report source at docmd.openreport?

  • Thread starter Thread starter SF
  • Start date Start date
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
 
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.
 
Back
Top