On error cancel event

Matizo

Registered User.
Local time
Yesterday, 18:14
Joined
Oct 12, 2006
Messages
83
Hi,

Quick question..

What code should there be between DoCmd.RunCommand acCmdDeleteRecord AND DoCmd.Close
If I don't enter any data I get a msg "Record cannot be deleted at this time.."
so I need a code that on error would cancel the event and carried on with closing the form.

This is the whole code:

Private Sub Exit_Click()
On Error GoTo Err_Exit_Click


DoCmd.RunCommand acCmdDeleteRecord
DoCmd.Close

Exit_Exit_Click:
Exit Sub

Err_Exit_Click:
MsgBox Err.Description
Resume Exit_Exit_Click

End Sub


Thanks!
 
Hi

Try this:

Private Sub Exit_Click()
On Error Resume Next



DoCmd.RunCommand acCmdDeleteRecord
DoCmd.Close

Exit_Exit_Click:
Exit Sub


End Sub


JOHN
 
Hi John,

It work perfectly,

Thanks!
 
Hi Matizo,

Glad to have been of help.

John
 
the trouble is that if you do that, the delete may or may not take place, and you dont know which - which can prove problematical.
 

Users who are viewing this thread

Back
Top Bottom