How to undo or prevent a record save from a cancel button?

  • Thread starter Thread starter Jovalle
  • Start date Start date
J

Jovalle

Guest
How do you prevent a form from automatically saving a record or at least invoking an undo function from a cancel button, as oppose to invoking it from the Access Menu - Edit > Undo Current Field/Record? This while adding a new record, and not editing an existing one. I'm using Access 2000 running on Win 98. I would appreciate some feedback on any script that does the function.
 
Thanks Pat,
I got the Cancel=True to work from the BeforeUpdate event of the subform.. however I need to ask you now on how to get the subform to update from an OK or Save button in the main form.. I tried a couple of methods including a boolean that is designed to control the flow of the script in the BeforeUpdate, but all apparently are being ignored and doesn't allow to save anything in the subform. Again, thanks in advance for any suggestions that you can offer.
 
Make a command button on your main form and call it save. Put the following code in its On Click Properties:
Private Sub Save_Click()
On Error GoTo Err_Save_Click


DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Exit_Save_Click:
Exit Sub

Err_Save_Click:
MsgBox Err.Description
Resume Exit_Save_Click

End Sub
 

Users who are viewing this thread

Back
Top Bottom