commands

maxmangion

AWF VIP
Local time
Today, 20:48
Joined
Feb 26, 2003
Messages
2,805
Can these three be used interchangeably:

Cancel = True
Me.Undo
DoCmd.CancelEvent

if no, which should be used when ?

Thanks
 
Me.Undo is like CTRL+z it's an undo, you cannot undo a close operation.

When Closing a form, ive noticed the DoCmd.CancelEvent errors, and only for me Cancel = True plain old dosent work.

They are three different things... that all share common aspects though.

Cancel = True *SHOULD* Cancel the block of code you're running.
DoCmd.CancelEvent *SHOULD* Cancel the current operation (like a query that's running or something... could be used to make a cancel button.)
Me.Undo *SHOULD* Undo userinput...
 
Cancel = True
Me.Undo
DoCmd.CancelEvent

Not at all interchangeable.

Cancel=True ONLY works when the event code where you try to use it supports cancellation. For instance, you cannot cancel a GotFocus event. You can tell because if you allow the wizard to build the event code shell, it will include an argument named Cancel in the formal argument list.

DoCmd.CancelEvent is one I never use, but I suppose you could use it to cancel an event of some sort. I would read and re-read the help files on this one a LOT before using it in preference to the other items you named.

Me.Undo is the moral equivalent of starting a BEGIN TRANSACTION but then doing a CANCEL rather than a COMMIT. I use it on forms a lot, less in other places. Particularly since the ME syntax is usually a form. (Theoretically, also a report, but that would not legally have anything to undo.)

Me.Undo is not necessarily event-based, either.
 

Users who are viewing this thread

Back
Top Bottom