Sandra Smith
asked on
User cancels report run but getting debug message box
I have a report that depends on critiera being passed at the form level. However, if the user cancels the process when the request for a date comes up, the error message 2501 comes up. I have code that works if the report is run directly and it works. Howevever, the error trap does not work in this sceanrios and I am wondering how to get around it. So, the user clicks on the button to run the report, the box requesting a date comes up and if they hit cancel, then the 2501 error box comes up. It may be placement of the error, but I do not know where.
Private Sub boxUserManStats_Click()
Dim intCancel As Integer
DoCmd.OpenReport "rptUserManStats", acViewPreview, , "tblProductionData.Division = 'EDS' AND " & _
"tblProductionData.DataSource = 'EDSManual' AND " & _
"tblProductionData.UserID = '" & Me.txtUserID & "' AND " & _
"tblProductionData.ActivityDate = [Enter Date in format of M/D/YYYY] "
Exit_ErrorHandler:
Exit Sub
ErrorHandler:
If Err.Number = 2501 Then
Exit Sub
Else
MsgBox Err.Number & ": " & Err.Description
Resume Exit_ErrorHandler
End If
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I need to get some sleep.......
ASKER
I am still working on the other issue as well.
Private Sub cmdPrintApp_Click()
On Error GoTo Err_cmdPrintApp_Click
DoCmd.OpenReport "SomeReportName", acPreview
Exit_cmdPrintApp_Click:
Exit Sub
Err_cmdPrintApp_Click:
If Err.Number = 2501 then ' You cancelled .....
' no action required
Else
MsgBox Err.Description
End If
Err.Clear
Goto Exit_cmdPrintApp_Click
End Sub
mx