Re: Dirty Event for Form is not "firing".



David W. Fenton wrote:
Salad <oil@xxxxxxxxxxx> wrote in
news:g07cf.1357$Xo.634@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx:



Allen Browne wrote:

No idea how that relates to the OP's q.

I may have misunderstood the following: "How should I deal with the situation when the User is working on a NewRecord and (supposedly) has filled in all the required fields and then hits the Close Button before hitting the Save button?"

I figured the Close button is the X button on the form's caption
bar next to the Min/Restore buttons instead of a oommand button on
the form with the caption Close.  It a user presses the X (close)
button a BeforeUpdate event will fire but is ignored and unless
the record already exists (not an newrecord) it will be lost.


But this is a classic known bug and it is handled by forcing the
save in the form's OnClose event, or getting rid of the form's Close
button and supplying your own that forces Me.Dirty = False before
closing the forme, which should throw errors if there are required
fields not filled out.



Hmmmm...I wonder if this bug will be removed in the new version of Access. Perhaps it's been around so long it's considered a feature.


The problem that I see is that the form has "unloaded" prior to hitting the OnClose event and if a BeforeUpdate event occurred that Canceled, the reset of the Autonumber/NewRecord will occur prior to that Close event.

Maybe by using a Type/EndType construct in the OnError event to ask the user whether or not to save could work by canceling the Unload and refilling the fields.
.