J
John S. Ford, MD
I have a dialog box that allows users to enter criteria that are used to
select records on another form. I use the following code to prevent the
form from opening if there are no records meeting the chosen criteria:
Private Sub Form_Open(Cancel As Integer)
On Error GoTo Err_Error
If Me.Recordset.RecordCount = 0 Then
Cancel = True
MsgBox "No admissions meet these criteria."
End If
CompletedRoutine:
Exit Sub
Err_Error:
If Err.Number = 2501 Then
Resume Next
Else
MsgBox Err.Number & Err.Description
Resume CompletedRoutine
End If
End Sub
The message box comes up as planned but I still get the 2501 error (The Open
Form action was canceled). Why is my code not suppressing this error
message?
Thanks in advance!
John
select records on another form. I use the following code to prevent the
form from opening if there are no records meeting the chosen criteria:
Private Sub Form_Open(Cancel As Integer)
On Error GoTo Err_Error
If Me.Recordset.RecordCount = 0 Then
Cancel = True
MsgBox "No admissions meet these criteria."
End If
CompletedRoutine:
Exit Sub
Err_Error:
If Err.Number = 2501 Then
Resume Next
Else
MsgBox Err.Number & Err.Description
Resume CompletedRoutine
End If
End Sub
The message box comes up as planned but I still get the 2501 error (The Open
Form action was canceled). Why is my code not suppressing this error
message?
Thanks in advance!
John