I think the question is, what am
I missing?
The code is a little more complicated than that. I'm sure this will all seem overcomplicated, but it has to do with preventing the form from closing only when suspicious data has been entered, but still allowing the user to close the form after a warning, just in case the data is actually correct. Because data integrity is a grey area in this case, I have to allow this. That said, here's how it works:
If the user enters suspicious data, the field's BeforeUpdate event offers the user the choice to save their changes or not. If they choose to save their changes, the event is allowed to proceed and everything unfolds normally. If they choose not to save, then BeforeUpdate is cancelled. A global boolean variable (booStopNavigation) is set to tell subsequent code that spurious data was entered and the user chose to correct it.
If the user was trying to move off the record, either by changing records or closing the form, a 2169 error is triggered (cannot save record). In the form's Error event code, I tell it to bypass the error (Response = acDataErrContinue). If the user was trying to move to another record, this stops them from moving on it's own, which is a happy coincidence. In this event, the dirty fields all retain their current entries.
If they were trying to close the form; however, this does not prevent the close event. So, I then tell the form's Unload event to cancel if booStopNavigation is set to True, which would indicate that the user had chosed to correct the error. After this booStopNavigation is reset to False so that the user can close the form normally if an error isn't triggered. (There is actually a tiny hole in this logic that would cause the user to have to click to close button twice in some very rare cases).
When the code runs through this way, all of the dirty fields on the form are reset. I checked if the form's Query event is firing, and it's not.
Clear as mud?