Help with Form Event

neilmcmor

Registered User.
Local time
Today, 02:05
Joined
Aug 9, 2007
Messages
70
I have a Form that uses a BeforeUpdate event to offer the user the chance to undo changes before saving. The code below works however I do not wish the form to clear its contents once the user clicks yes as I would like the user to have the ability to then go onto add data into the subform contained within this form. Any Idea?

Private Sub Form_BeforeUpdate(Cancel As Integer)

'Provide the user with the option to save/undo
'changes made to the record in this form

If MsgBox("Clicking YES will save these deatils!" _
& vbCrLf & vbCrLf & "Do you wish to commit these changes?", _
vbYesNo, "Do You Require These Changes Made...") = vbYes Then
DoCmd.Save
Else
DoCmd.RunCommand acCmdUndo
End If

End Sub
 
DoCmd.Save is not for saving forms. You want DoCmd.RunCommand acCmdSaveRecord. You can also replace DoCmd.RunCommand acCmdUndo with Me.UnDo!
 
Try going into the form's property box, click on Other tab the set Cycle to Current Record.

And also, I don't think you can force a save in the Form_BeforeUpdate event, I think that'll throw an error, I believe. When the user moves to the subform, the record will be saved, by default.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom