CancelEvent


Cancels a cancelable event (an event that has a Cancel parameter).

Syntax

DoCmd.CancelEvent()

Example

The following example displays a dialog asking the user whether he or she wants to save changes to a record. If the user clicks the No button, then the CancelEvent method is called to cancel the update.

Private Sub Form_BeforeUpdate(Cancel As Integer)   If MsgBox("Are you sure you want to save changes to this record?", _   vbYesNo Or vbInformation, "Confirm Upate") = vbNo Then   DoCmd.CancelEvent   End If End Sub 

Comments

  • The CancelEvent method can only be called inside an event procedure.

  • Calling the CancelEvent method is equivalent to setting an event handler’s Cancel parameter to True.

  • If an event is not cancelable (has no Cancel parameter), calls to the CancelEvent method have no effect.




Access VBA Programming
Microsoft Access VBA Programming for the Absolute Beginner
ISBN: 1598633937
EAN: 2147483647
Year: 2006
Pages: 214
Authors: Michael Vine

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net