S
Secret Squirrel
I'm trying to use a popup message when a users clicks the close button on my
form to ask them if they want to exti without saving. If they click ok then
have it undo any changes to the record and if they click cancel then have it
do nothing so they can then click the save button. But for some reason (and
it's driving me crazy) every time they click the close button it prompts them
with my message....even when nothing has changed with the record. The way I
want it set up is if nothing has changed with the current record then when
they click close have it just close without asking them anything. Can anyone
see what I'm doing wrong?
If Form.NewRecord Then
If MsgBox("Are you sure you want to exit without saving?",
vbOKCancel) = vbOK Then
Me.Undo
DoCmd.Close
Else
'don't do anything if cancel is clicked
End If
Else
If Me.Dirty = True Then
If MsgBox("Are you sure you want to exit without saving?",
vbOKCancel) = vbOK Then
Me.Undo
DoCmd.Close
Else
'don't do anything if cancel is clicked
End If
Else
DoCmd.Close
End If
End If
form to ask them if they want to exti without saving. If they click ok then
have it undo any changes to the record and if they click cancel then have it
do nothing so they can then click the save button. But for some reason (and
it's driving me crazy) every time they click the close button it prompts them
with my message....even when nothing has changed with the record. The way I
want it set up is if nothing has changed with the current record then when
they click close have it just close without asking them anything. Can anyone
see what I'm doing wrong?
If Form.NewRecord Then
If MsgBox("Are you sure you want to exit without saving?",
vbOKCancel) = vbOK Then
Me.Undo
DoCmd.Close
Else
'don't do anything if cancel is clicked
End If
Else
If Me.Dirty = True Then
If MsgBox("Are you sure you want to exit without saving?",
vbOKCancel) = vbOK Then
Me.Undo
DoCmd.Close
Else
'don't do anything if cancel is clicked
End If
Else
DoCmd.Close
End If
End If