CancelEvent Method [Access 2003 VBA Language Reference]

The CancelEvent method carries out the CancelEvent action in Visual Basic.


expression Required. An expression that returns a DoCmd object.


This method has no arguments and can be called directly using the syntax DoCmd.CancelEvent.

The CancelEvent method has an effect only when it's run as the result of an event. This method cancels the event.

All events that can be canceled in Visual Basic have a Cancel argument. You can use this argument instead of the CancelEvent method to cancel the event. The KeyPress event and MouseDown event (for right-clicking only) can be canceled only in macros, not event procedures, so you must use the CancelEvent action in a macro to cancel these events.

Applies to | DoCmd Object