I have a button to print a report. Can I set it up to print multiple copies of the same report? I've looked in the help, but can't find the answer. Any ideas? Thanks.
Make Print Dialog Box appear when printing a Report
Add the following to the "On Activate" event of the report. This will cause the Print Dialog Box to open so you can choose a printer, and also choose the number of copies .... ect.
After you make the choices in the Printer Dialog Box the report will print ... but the code will close the report without it ever appearing on screen.
There is also code here in case the result of the recordset returns "no records" so there's no need to use the On No Data event. It will display a message box that you can alter to fit your needs.
Code:
'---------------Code Start-----------------------
Private Sub Report_Activate()
On Error GoTo Err_Report_Activate
Dim strMsg As String
Dim strTitle As String
strMsg = "There Were No Records Returned." & vbCrLf & "Print has been Cancelled."
strTitle = " No Records Returned"
If Me.Report.HasData Then
DoCmd.RunCommand acCmdPrint
DoCmd.Close acReport, Me.Name
Else
MsgBox strMsg, vbInformation + vbOKOnly, strTitle
DoCmd.Close acReport, Me.Name
End If
Err_Report_Activate:
Resume Next
DoCmd.Close acReport, Me.Name
End Sub
'---------------Code End-------------------------
That's what I need. The code is almost exactly what I had. However, when I tried this it printed the current form that called the procedure. I guess I'm unclear on what causes this to print the report I'm trying to refer to in the first part of the code.