MattBaldry
Self Taught, Learn from the Forums
- Local time
- Today, 01:28
- Joined
- Feb 5, 2019
- Messages
- 292
Hello forums,
I have the below code in my form BeforeUpdate event.
If Me.Dirty = True Then
Select Case MsgBox("Do you want to save changes to this record?", vbYesNoCancel, "Save Changes")
Case vbYes
DoCmd.RunCommand acCmdSaveRecord
Case vbNo
Screen.ActiveForm.Undo
Case vbCancel
DoCmd.CancelEvent
End Select
End If
So the user clicks close and then this event fires. Is there a way that if they click vbCancel that the DoCmd.Close command from my close button does not fire?
I know I can use the above code as part of the close button, but I wondered if there is a way to do it like this.
~Matt
I have the below code in my form BeforeUpdate event.
If Me.Dirty = True Then
Select Case MsgBox("Do you want to save changes to this record?", vbYesNoCancel, "Save Changes")
Case vbYes
DoCmd.RunCommand acCmdSaveRecord
Case vbNo
Screen.ActiveForm.Undo
Case vbCancel
DoCmd.CancelEvent
End Select
End If
So the user clicks close and then this event fires. Is there a way that if they click vbCancel that the DoCmd.Close command from my close button does not fire?
I know I can use the above code as part of the close button, but I wondered if there is a way to do it like this.
~Matt