Thank you John. Running that code in the Cancel button Click event produces this error: Run-time error '2455': You entered an expression that has an invalid reference to the property Dirty.
Wonder if Me in Me.Dirty is pointing to the Cancel button rather than the form?
Steve
Steve-
Check the Dirty property of the form in the Click event of your Cancel button.
If Me.Dirty = True Then
If vbNo = MsgBox("You have unsaved changes. Are you sure you want to cancel?", _
vbQuestion + vbYesNo + vbDefaultButton2) Then Exit Sub
End If
End If
John Viescas, Author
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications
SQL Queries for Mere Mortals
http://www.viescas.com/
(Paris, France)
On Jun 6, 2016, at 10:37 PM, Steve thaw5 thaw5@suddenlink.net [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:
I have a form which presents an existing record to the user. The form
has a Save And Close command button as well as a Cancel button.
The user can edit any of the ten or so text fields and then click Save
And Close to save the revised record to the database. But sometimes the
user inadvertently clicks Cancel and desired changes are lost.
If changes were made to the form, then when the user clicks Cancel I'd
like to remind him that changes were made and ask for confirmation that
he really wants to close the form without saving the changes. How can I
know if any of the text fields were changed?
Thanks. Steve
------------------------------------
Posted by: Steve thaw5 <thaw5@suddenlink.net>
------------------------------------
------------------------------------
Yahoo Groups Links
Posted by: Steve5 <thaw5@suddenlink.net>
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (3) |
Tidak ada komentar:
Posting Komentar