Using acCmdUndo and reverting form fields

Ruth

Registered User.
Local time
Today, 10:12
Joined
Jan 28, 2009
Messages
16
I'm using a msgbox to ask the user if they want to save changes in a continuous form for editing existing records. If they don't want to save before going to the next record, I have the acCmdUndo line in the code. It doesn't save the record and it sends the focus back where I want, but it doesn't change the form fields back to the existing record. Is there a way to do that or am I missing something?

Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
    If MsgBox("You have Updated the Record" & vbCrLf & " Do You Want To Save It?", 
        vbQuestion + vbYesNo, "Save Record?") = vbYes Then
        'save record
    Else
        'Dont save it up
        DoCmd.RunCommand acCmdUndo
        Me!txtInvoice_Number.SetFocus
        Exit Sub              'return to the form for correction.
    End If
End Sub

Thanks for any help.
 
You need to issue

Cancel = True

and then undo

Me.Undo
 
Perfect! Thank you Bob
 

Users who are viewing this thread

Back
Top Bottom