How do you know if Form_BeforeUpdate is triggered by the form being closed?

  • Thread starter Thread starter Peter R. Fletcher
  • Start date Start date
P

Peter R. Fletcher

I use Form_BeforeUpdate to check for data sanity before the User is
allowed to proceed to the next record on a form. If the sanity check
fails, the Event is cancelled and the user gets to try again! This
works fine, except if the Before_Update Event is triggered by the form
closing (for various reasons, I would like to continue to allow the
user to have access to the regular X button). If the BeforeUpdate
event is cancelled under these circumstances, you get (or have to
trap) Access's "You can't save this record at this time" error. Is
there any way of finding out that the BeforeUpdate Event was triggered
by an attempt to close the form, rather than (e.g.) an attempt to move
to a different record.
 
I'm not aware of any way (fudge or otherwise) to detect that they have
clicked the close box. So the easiest way to handle this would be to give
them a Close button and >not< let them use the close box. Then the button
can set a flag for form_beforeupdate.

HTH,
TC
 
I was afraid of that!

I'm not aware of any way (fudge or otherwise) to detect that they have
clicked the close box. So the easiest way to handle this would be to give
them a Close button and >not< let them use the close box. Then the button
can set a flag for form_beforeupdate.

HTH,
TC
 
Back
Top