Hi,
You could use this subroutine, placed in a regular (not class,not
report, not form) module:
Public Sub PrintAReportShowingPrintDialog(ByVal strReportName As String)
On Error GoTo Handle_Error
DoCmd.OpenReport strReportName, acViewPreview
DoCmd.RunCommand acCmdPrint
Exit_Sub:
On Error Resume Next
DoCmd.Close acReport, strReportName, acSaveNo
Exit Sub
Handle_Error:
If Err.Number <> 2501 Then
' 2501 occurs when user cancels the print dialog box
MsgBox "Error #" & Err.Number & ": " & Err.Description
End If
Resume Exit_Sub
End Sub
Then when you want to print, simply use:
PrintAReportShowingPrintDialog "rptMyReportName"
You may need to add more error numbers to check if any reportsprompt
for parameters, for when the user cancels the parameter prompt dialog.
Hope that helps,
Clifford Bass
- Show quoted text -