I'm unable to trap an Error 2501 that occurs when I cancel the acCmdPrint print dialog.
Here's my code:
The error I get is a Microsoft Visual Basic Error:
Run-Time error '2501':
The RunCommand action was canceled.
The error seems to pop up before it gets to my 'CmdPrint_Click_Error:'. It appears to be generated by the print dialog.
How can I trap this error?
Thanks, Sup
Here's my code:
Code:
Private Sub CmdPrint_Click()
On Error GoTo CmdPrint_Click_Error
If Forms![frmEquipmentRates]![FrameSort] = 1 Then
DoCmd.OpenReport "rptEquipRateAlpha", acViewPreview
DoCmd.RunCommand acCmdPrint
DoCmd.Close acReport, "rptEquipRateAlpha"
Else
DoCmd.OpenReport "rptEquipRateNum", acViewPreview
DoCmd.RunCommand acCmdPrint
DoCmd.Close acReport, "rptEquipRateNum"
End If
CmdPrint_Click_Error:
If Err.Number = 2501 Then
Err.Clear
Else
MsgBox "Error " & Err.Number & " (" & Err.Description & ")"
End If
End Sub
The error I get is a Microsoft Visual Basic Error:
Run-Time error '2501':
The RunCommand action was canceled.
The error seems to pop up before it gets to my 'CmdPrint_Click_Error:'. It appears to be generated by the print dialog.
How can I trap this error?
Thanks, Sup