Jul 5 2007, 04:02 PM
In the attached Dbase the main form that opens has a button with text "Example Yes/No/Cancel"
How can I use this button so that
a. whenever changes have been made to data. It will prompt with the message "Do you want to Save the Changes?"
User can then choose either of the Options Yes/No / Cancel
Yes will save the data and move to next record
No will keep the original data and move to the next record
Cancel will keep the original data and move to the next record
Can this be done?
Your help appreciated
Jul 5 2007, 04:18 PM
I would put the code in the Forms Before Update event so it will fire no matter how the user decides to leave the form.
If Me.Dirty Then
Select Case MsgBox("Do you want to Save Changes!", vbYesNoCancel Or vbDefaultButton1 Or vbExclamation, "Title: Click Yes, No Or Cancel!")
This is completely and totally UNTESTED so BEWARE!
Jul 5 2007, 04:27 PM
You are too good - That works fine
How do I make it go to the next record after they have chosen their option?
Jul 5 2007, 04:34 PM
I do not know how your form is set up, but usually they will tab through the form and it will go to the next record when they exit the last control, at which time the Before Update event will fire. It should go to the next record...
REMEMBER! All of this is UNTESTED and coming from my fevered brain...
Jul 5 2007, 04:56 PM
Your fevered brain is working like clockwork
It works a treatMany thanks once again
Jul 5 2007, 05:03 PM
I do not know how your form is set up, but usually they will tab through the form and it will go to the next record when they exit the last control, at which time the Before Update event will fire.
This is not quite accurate. The Before Update event does NOT fire unless the form is dirty. If the form is not dirty then the Before Update event does not fire so be careful in how you use it. Also, if you use the Before Update event, you don't have to test to see if it is dirty in the Before Update event. So the earlier code about
If Me.Dirty Then...
is redundant and not required.
Jul 5 2007, 05:05 PM
You are most welcome and thank goodness for small favors! Glad to hear that my fevered brain was/is working... Tis 39.5C today.... PHEW!
Jul 5 2007, 05:07 PM
Very 'cool' information! Thank you for sharing it....now all I have to do is find some spare room in my memory banks in which to save it... So much yet to learn and so little time left...
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here