Hide err 2501

hbeer444

Brian Rypstra
Local time
Yesterday, 17:17
Joined
Sep 3, 2009
Messages
15
Please help I am trying to stop the err msg 2501 after the cancelling the open event - I tried on error resume next - didn't work
Help

access 2003 VBA

the following is a simplified example in a form's module:

Option Compare Database
Option Explicit

Private Sub Form_Open(Cancel As Integer)

if msgbox("Don't open the Form?",vbOKCancel) = vbCancel then
Cancel = True
Exit Sub
end if

...other stuff here

end sub


Thanks kindly in advance!
 
Try next:

Private Sub Form_Open(Cancel As Integer)
On Error go to ErrOpen
if msgbox("Don't open the Form?",vbOKCancel) = vbCancel then
Cancel = True
GoTo OpenExit
end if

...other stuff here

OpenExit:
Exit Sub


ErrOpen:
If Err <> 2501 Then
MsgBox Err.Description
End If
Resume OpenExit

end sub
 
Thanks but it doesn't work:

When the code finishes

OpenExit:
Exit Sub


the error msg still shows.

I've tried everything I know!
 
In order to stop the Error 2501, you need to use an error handler on the event that OPENED the form, not the form that is opening.
 

Users who are viewing this thread

Back
Top Bottom