Hi I have a form in which there is a close button (cmdClose). I want the prompt to request for Discard. If yes discard and close form. If No to Set focus to previous control. And if no change close the form. I am having trouble getting this to work. Would appreciate your advice.
If Me.Dirty = True Then
If MsgBox("Discard the changes?", vbYesNo, "Discard") = vbNo Then
Screen.PreviousControl.SetFocus
Else
DoCmd.Close , "frmRequest", acSaveNo
End If
End If
If Me.Dirty = True Then
If MsgBox("Discard the changes?", vbYesNo, "Discard") = vbNo Then
Screen.PreviousControl.SetFocus
Else
DoCmd.Close , "frmRequest", acSaveNo
End If
End If