Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Discard Form On Close Button

Status
Not open for further replies.

StanJx

Programmer
Jun 2, 2016
29
LK
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
 
I believe you need acForm between Close and the form's name.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top