Accept reject changes dialogue box

Bruce75

Psychologist
Local time
Today, 18:41
Joined
Sep 29, 2004
Messages
46
Hello,

Once again I would be grateful for any help or advice...

Is there a way of creating a message box appear that asks the user if they want to accept or reject the changes that they have made on a record from a form? I would like this to appear only if the current record has been changed - just in case the user made the change by accident, and cannot remember what they need to change it back to.

thanks

Bruce
 
Put it in the form's BEFORE UPDATE event. And then if they choose to not commit the changes use:

Cancel = True
Me.Undo

and if they want to save it, just let it go through; no other code necessary.
 
thanks for your really quick reply. Unfortunately, I still have a problem though.

I am a total beginner with VBA and have manage to cobble together this:

Private Sub Form_BeforeUpdate(Cancel As Integer)

Dim Response As Integer

Response = MsgBox("Do you wish to save the changes that you have made?", vbYesNo, "Save changes?")

If Response = vbNo Then

Cancel = True
Me.Undo
End If


Cancel = True
Me.Undo

End Sub

It seems to be able to identify when I have made changes to the mainform but not the subforms. Also, if I choose Yes (I want to keep the changes) it does not save them. Any ideas what I am still doing wrong?

Cheers
 
If you have subforms, the main form record gets saved automatically right when you navigate to the subform and the subform gets saved automatically if you navigate back to the main form. You can't "undo" a record after it's been saved by going to the subform and back. So, you would need to come up with some way to delete the record created in the main form if they used your code from the Before Update event of the subform.
 
thanks again.

my first problem was caused by repeating the same bit of code twice after the end if.

I have stuck the code in the before update property of the subform, and this seems to do the trick.

cheers for you advice
 

Users who are viewing this thread

Back
Top Bottom