View Single Post
  #5  
Old June 6th, 2010, 04:18 AM posted to microsoft.public.access
PeterM
external usenet poster
 
Posts: 208
Default Close Form Event

Thanks John!

"John W. Vinson" wrote:

On Fri, 4 Jun 2010 22:00:58 -0700, PeterM
wrote:

I don't think I've explained the problem clearly. I have the save button
setup the way you define in your example. How do I capture if the user
changes a bound item on a form and tries to close the form without clicking
on the save button first. There is no close button on the form, a form is
closed by a parent form when another form is opened. I need to determine
when the form is closed but still is dirty. THe unload and close events
don't work in that situation.


Use the form's BeforeUpdate event. It will fire if any field value is changed
and any action is taken that would save it (such as closing the form, pressing
Shift-Enter, etc.) You can set the value of a public variable in the
legitimate "close" button and check that variable's value in the BeforeUpdate
event; if you don't want to save the record, issue a message and set the
event's Cancel parameter to True.
--

John W. Vinson [MVP]
.