on my form, I have a "Cancel" button which allows user to cancel updates and here is my code:
the above code will close the form without save the form when user click on the 'cancel' button. What I would like to do is to add option Yes or No when user click on Cancel button. When user chooses Yes, form will be closed without saving the changes. When user chooses No, message box close and form stay openw with the changes. Here is my code, but it doesn't work properly
any help would be grealy appreciated.
bluemoon
Code:
Dim db As Database Dim frm As Form Set db = CurrentDb Set frm = Forms!frmReview If Me.Dirty Then 'Check to see if record has been updated. DoCmd.RunCommand acCmdUndo DoCmd.Close acForm, "frmReview" Else DoCmd.Close acForm, "frmReview" End If End sub
Code:
Dim db As Database Dim frm As Form Set db = CurrentDb Set frm = Forms!frmReview_V2 MsgBox "Cancel? Select Yes or No", vbYesNo, "Cancel Update!" if vb=Yes then DoCmd.RunCommand acCmdUndo DoCmd.Close acForm, "frmReview" elseif vb=No then DoCmd.RunCommand acCmdUndo End If end sub
bluemoon
Comment