Hello I have the code below (I am a bit confused by the If statements and YES NO message box.
I want to use the code to check if the form is dirty (it references a check box that is set when the form is dirty)
If dirty a message box pops up saving "do you want to save changes..." - if the user chooses Yes then the form
will close and if the user chooses NO the me.undo command will run and then the form will close.
Is my logic OK here?
I would appreciate someone looking at the code as I realise something is wrong as I have 2 Ifs - but not quite sure what to do!
Thanks Mark
I want to use the code to check if the form is dirty (it references a check box that is set when the form is dirty)
If dirty a message box pops up saving "do you want to save changes..." - if the user chooses Yes then the form
will close and if the user chooses NO the me.undo command will run and then the form will close.
Is my logic OK here?
I would appreciate someone looking at the code as I realise something is wrong as I have 2 Ifs - but not quite sure what to do!
Code:
If Me.txt_dirty = True Then
DoCmd.SetWarnings False
If MsgBox("prompt", vbYesNo, "Do you want to SAVE CHANGES?") = vbYes Then
DoCmd.Close acForm, "frm_tab_member", acSaveNo
MsgBox "Changes SAVED", , "Status"
Else
Me.Undo
DoCmd.Close acForm, "frm_tab_member", acSaveNo
MsgBox "Changes NOT SAVED", , "Status"
End If
DoCmd.SetWarnings True
End If
Thanks Mark