I'm having some troubles understanding the Dirty event and its Cancel option. What I'm needing to do is, on close, have the form undo any current changes to the new record so that they're not saved on close. From what I've read, it seems that the Dirty event can be cancelled and anything added since first dirtying can be cleaned.
Can someone help out? Thanks a million!
UPDATE: I tried using the form.Undo method and this doesn't work because if they hit the "X" to close it, it updates the record before closing. I guess I'll try the Unload or other similar event.
Only workaround of this porblem I know is disabling the X (close) button on form and and offer your own Cancel and OK buttons. which you can undo and exit when cancel clicked, or you can save data if OK clicked.
for cancel button:
I had thought of this resolution, but the only problem with it is that they can close the window by right-clicking on the taskbar window and selecting close that way. That leaves an unchecked record in the main records. I'm not really sure how to incorporate the Undo with the close events (unload, close, etc.) because it's already tried to update before that happens. :-\
I believe this would work if I wanted to place a button on the form that they had to use to close the form. However, I'd prefer for them to not lose the freedom and ease of just closing the form with the "X" or right-clicking the taskbar. Unload and Close events occur AFTER the new record has been formed.
I'm trying to catch the spot between where you click on the "X" to close it and when it adds/updates the new record. If anyone could help me on that, I'd greatly appreciate it.
Hey, ghozy, or anyone else interested for that matter:
I've chosen to do the close button using the method introduced at that link you sent. Works great.
I tried using the same idea to prevent an Update to happen by declaring an AllowSave and if this was False, then it would Cancel the BeforeUpdate event. However, it seems to be half working. I have set up exactly like the AllowClose.
Declare public AllowSave variable as Boolean.
Put in Form_Load, AllowSave = False.
In Save button's Click event, AllowSave = True.
Then, in BeforeUpdate, Cancel = Not AllowSave at the beginning of the event.
It cancels the updating of the record but keeps going with the other statements in the BeforeUpdate procedure. Got any tips? Need more clarification, just ask! Thanks!