ScrmingWhisprs
05-07-2007, 12:16 PM
I have the following code in the OnClick event of a button that opens a report. I'm not that fluent with error handling code, so i'm not sure if I have all of this in the right place:Private Sub cmdViewReport_Click()
On Error GoTo Err_Report_Click
DoCmd.OpenReport "On Search", acViewPreview
Err_Report_Click:
If Err.Number = 2501 Then
Resume Next
Else
MsgBox Err.Description
Resume Exit_Report_Click
End If
If Me.Frame43.Value = 3 Then
If IsNull(txtAfter) Then
DoCmd.Close acReport, "On Search", acSaveNo
MsgBox "You must enter an After date.", vbExclamation, "Report Error"
End If
If IsNull(txtBefore) Then
DoCmd.Close acReport, "On Search", acSaveNo
MsgBox "You must enter a Before date.", vbExclamation, "Report Error"
End If
End If
End Sub
When I click the command button I get a Compile error: Label not defined. Message box. The line Resume Exit_Report_Click is highlighted in the code.
What am I doing wrong?
ScrmingWhisprs
On Error GoTo Err_Report_Click
DoCmd.OpenReport "On Search", acViewPreview
Err_Report_Click:
If Err.Number = 2501 Then
Resume Next
Else
MsgBox Err.Description
Resume Exit_Report_Click
End If
If Me.Frame43.Value = 3 Then
If IsNull(txtAfter) Then
DoCmd.Close acReport, "On Search", acSaveNo
MsgBox "You must enter an After date.", vbExclamation, "Report Error"
End If
If IsNull(txtBefore) Then
DoCmd.Close acReport, "On Search", acSaveNo
MsgBox "You must enter a Before date.", vbExclamation, "Report Error"
End If
End If
End Sub
When I click the command button I get a Compile error: Label not defined. Message box. The line Resume Exit_Report_Click is highlighted in the code.
What am I doing wrong?
ScrmingWhisprs