View Full Version : Running Reports


Galstar
02-24-2005, 03:04 PM
I have several objects on the form that allows me to print reports. One object shold allow me to run the report but with a different query due to the math.

How if open/runnign report from button can i chaneg the recordsource of the report?

Private Sub PTReport_Click()
On Error GoTo Err_PTReport_Click

Dim stDocName As String
If Forms!Reports!Math = "<" Then

DoCmd.OpenReport stDocName, acViewPreview
Reports.RPT_AFPT_Results.RecordSource = "qry_APFT_Results"

Else
DoCmd.OpenReport stDocName, acPreview
Reports!RPT_AFPT_Results.RecordSource = "qry_APFT_ResultsII"

End If

The lines in red will not run. I know this becuase the report is already open. Can you pass info to the report when it is opening??

pbaldy
02-24-2005, 03:44 PM
Try in the open event of the report.