[AccessD] Cancel the closing of a form

Steve Schapel miscellany at mvps.org
Wed Sep 5 00:21:12 CDT 2007


Rusty,

Simply use the Before Update event of the form.

If the current record has not changed, the Before Update event will not 
occur.

If the current record has changed, the code that fires could be along 
these lines:

    Dim answer As Integer
    answer = MsgBox("Save changes?", vbYesNoCancel)
    If answer = vbNo Then
       Me.Undo
    ElseIf answer = vbCancel Then
       Cancel = True
    End If

Regards
Steve


rusty.hammond at cpiqpc.com wrote:
> I have a form that when I close it either from a close button on the form or
> from the built in close button, I want to test if the current record has
> changed.  If it has changed, I want to prompt the user to either Save the
> record and go ahead and close the form, not save the record and close the
> form, or not save the record and not close the form via a YesNoCancel
> message box.
> 
> If I use the close event of the form testing for me.dirty doesn't work
> because the record is already saved.
> 
> Is there any way to do this?



More information about the AccessD mailing list