In the before update event of the form, you can do some of the following
- allow the save
- cancel the save (go back to the form as it was)
- undo
I don't think you can close the form there, but if the before update is triggered by trying to close the form, allowing the save or performing an undo, will probably allow the process (of closing the form) to proceed. A shortened version might perhaps look something like this.
[tt]retval = msgbox("Yes - save, No - undo, cancel - return to form", _
vbYesNoCancel,"???")
select case retval
case vbyes
' do nothing
case vbno
me.undo
case else
cancel = true
end select[/tt]
- typed, not tested.
You can off course also trigger this message only when the user attempts to close the form. This would probably mean to disallow the x button, and use a custom close button, setting a form public/private variable to test in the before update...
Roy-Vidar