I have button on my form that should exit the form. When this button is clicked, a message box prompts you to "save changes?" with a yes or no. Unfortunately, regardless of whether 'yes' or 'no' is clicked the code below does not save changes:
Private Sub Prekid_Click()
If Me.Dirty Then If MsgBox("Da li želite da saèuvate promene?", vbYesNo) = vbYes Then Upisivanje_Click
DoCmd.RunCommand acCmdUndo
Forms!Pregled!LicencaList.Form.Requery
DoCmd.Close acForm, Me.Name
End Sub
Doing If ... Then ...
in a single line can be confusing, as you have just demonstrated. :)
You code should be:
Private Sub Prekid_Click()
If Me.Dirty Then
If MsgBox("Da li želite da saèuvate promene?", vbYesNo) = vbYes Then
Call Upisivanje_Click
Else ' No case
DoCmd.RunCommand acCmdUndo
End If
End If
Forms!Pregled!LicencaList.Form.Requery
DoCmd.Close acForm, Me.Name
End Sub
acCmdUndo
should only run in the Else case (if No
was clicked).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.