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] "
If Err.Number = 2501 Then
MsgBox Err.Number & ": " & Err.Description