Specify report recordset

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

Guest

Hi

I have report call rptDelivery_Note on the click of one button i want the
report to open using a query qryPacking_Lists as the record source and on the
other button i have i want the report to open using qryDelivery_Note as the
record source.

Is this possible?

Thanks
 
Assuming both queries have all of the fields that the report uses, save the
report without anything in its RecordSource. Then in its Open event, you can
assign the source that you want.

Private Sub Report_Open(Cancel As Integer)
If Me.OpenArgs = "qryDeliveryNote" Then
Me.RecordSource = "qryDeliveryNote"
Else
Me.RecordSource = "qryPacking_Lists"
End If
End Sub

Now in the button that opens the report for qryDeliveryNote, use OpenArgs to
specify the other query, e.g.:
DoCmd.OpenReport "Report1", acViewPreview, OpenArgs:="qryDeliveryNote"

If you are using Access 2000 or earlier, you will need to use a public
string variable instead of OpenArgs.
 

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

Back
Top