Senin, 06 Juni 2016

Re: [MS_AccessPros] Changes made to form

 

Steve-


Works fine for me.  Is the form bound?  (Has a Record Source.)  If not, then the Dirty property might not exist.  If you're using unbound controls, then you'll have to keep a module level variable and set it in the AfterUpdate event of each editable control.  Test that in both Cancel and Save.  In Save, reset it.

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 
(Paris, France)



On Jun 6, 2016, at 11:22 PM, Steve5 thaw5@suddenlink.net [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:



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

On 6/6/2016 4:51 PM, John Viescas JohnV@msn.com [MS_Access_Professionals] wrote:

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: John Viescas <johnv@msn.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (5)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.


.

__,_._,___

Tidak ada komentar:

Posting Komentar