G
Guest
Hello.
I have a form with parameters, so the user can enter the start date and end
date and then click on Preview to run the report. The form has a Preview
error handling code. If the form is closed without clicking preview, the form
shuts nicely.
However, I have this report set to run from an Option button on a
switchboard form, that in itself has a Preview button: I click the option
button, then click on the switchboard Preview button, the parameter form
opens (where I could enter the parameter dates and click Preview to run the
report- but here I don't), I close the parameter form without entering
anything and get: "Error in procedure cmdPreview_Click, Error 2501: The
OpenReport action was canceled."
I thought I had trapped this error.
This is the error handling I have on the switchboard:
Private Sub cmdPreview_Click()
On Error GoTo ProcError
DoCmd.OpenReport Report_Name, acPreview
ExitProc:
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure cmdPreview_Click..."
Resume ExitProc
End Sub
Private Sub Report_Error(DataErr As Integer, Response As Integer)
PrintPreport_Error:
If Err.Number <> 2501 Then
GoTo ProcError
End If
ExitProc:
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure Report_Error..."
Resume ExitProc
End Sub
Private Sub Report_NoData(Cancel As Integer)
On Error GoTo ProcError
MsgBox "No data meets the report criteria.", vbInformation + vbOKOnly,
"Animals Deceased"
Cancel = True
ExitProc:
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure Report_NoData..."
Resume ExitProc
End Sub
Obviously, I don't have it quite right. I'd appreciate your help in trapping
the dreaded 2501.
Thanks!
I have a form with parameters, so the user can enter the start date and end
date and then click on Preview to run the report. The form has a Preview
error handling code. If the form is closed without clicking preview, the form
shuts nicely.
However, I have this report set to run from an Option button on a
switchboard form, that in itself has a Preview button: I click the option
button, then click on the switchboard Preview button, the parameter form
opens (where I could enter the parameter dates and click Preview to run the
report- but here I don't), I close the parameter form without entering
anything and get: "Error in procedure cmdPreview_Click, Error 2501: The
OpenReport action was canceled."
I thought I had trapped this error.
This is the error handling I have on the switchboard:
Private Sub cmdPreview_Click()
On Error GoTo ProcError
DoCmd.OpenReport Report_Name, acPreview
ExitProc:
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure cmdPreview_Click..."
Resume ExitProc
End Sub
Private Sub Report_Error(DataErr As Integer, Response As Integer)
PrintPreport_Error:
If Err.Number <> 2501 Then
GoTo ProcError
End If
ExitProc:
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure Report_Error..."
Resume ExitProc
End Sub
Private Sub Report_NoData(Cancel As Integer)
On Error GoTo ProcError
MsgBox "No data meets the report criteria.", vbInformation + vbOKOnly,
"Animals Deceased"
Cancel = True
ExitProc:
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure Report_NoData..."
Resume ExitProc
End Sub
Obviously, I don't have it quite right. I'd appreciate your help in trapping
the dreaded 2501.
Thanks!