How to: Cancel an Event

Access Developer Reference

Under some circumstances, you may want to include code in an event procedure that cancels the associated event. For example, you may want to include code that cancels the Open event in an Open event procedure for a form, preventing the form from opening if certain conditions are not met.

You can cancel the following events:

ApplyFilter
BeforeDelConfirm
BeforeInsert
BeforeRender
BeforeUpdate
CommandBeforeExecute
DblClick
Delete
Dirty
Exit
Filter
NoData
Open
Undo
Unload

You cancel an event by by setting an event procedure's Cancel argument to True.