Access 2000: Save Changes Option on a form

P

paquer

I put the following code into the Before Update section of my form;

Private Sub Form_BeforeUpdate(Cancel As Integer)

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

If MsgBox("Changes have been made to this record." _
& vbCrLf & vbCrLf & "Do you want to save these changes?" _
, vbYesNo, "Changes Made...") = vbYes Then
DoCmd.Save
Else
DoCmd.RunCommand acCmdUndo
End If
Last_Updated = Now()
End Sub

I later found out that DoCmd.Save attempts to save the design of the
form, therefore I removed it from the code.
I tried acCmdSave & acCmdSaveRecord but that only produced RunTime
2115 errors...
Right now the code has no Cmd for saving (when they choose the "Y"
option, its just the autosave.

What line of code can I use to give the user the option to save the
Record in the table without affecting the form design or producing
RunTime errors?
 
A

Allen Browne

You don't need anything.

Form_BeforeUpdate doesn't fire unless Access is about to save the record. If
you do nothing, the save proceeds. If you want to block the save, just set
the Cancel argument to True.

If MsgBox("Changes have been made to this record." _
& vbCrLf & vbCrLf & "Do you want to save these changes?" _
, vbYesNo, "Changes Made...") = vbYes Then
Last_Updated = Now()
Else
Cancel = True
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top