how to disable auto-save

T

Tony

I built a database using Microsoft Access. I don't want it to automatically
save anything when I click out of the forms or tables. I want to manually
click on a established save buttons. Please help.
 
A

Allen Browne

To block the save, cancel the BeforeUpate event of the form, unless the save
occurred through your Save button.

1. Open the module of the form. In the General Declaration section (top,
with the Option statements), enter:
Dim mbAllowSave As Boolean

2. Set the On Click property of your Save button to:
[Event Procedure]
Click the Build button (...) beside this.
Access opens the code window.
Set up the code to look like this:
Private Sub cmdSave_Click()
On Error Goto Err_Handler
If Me.Dirty Then
mbAllowSave = True
Me.Dirty = False
End If
Exit_Handler:
mbAllowSave = False
Exit Sub
Err_Handler:
MsgBox Err.Description,, "Save failed"
Resume Exit_Handler
End Sub

3. Set up the code for your cancel button like this:

Private Sub cmdCancel_Click()
If Me.Dirty Then
Me.Undo
End If
'DoCmd.Close acForm, Me.Name, acSaveNo
End Sub

4. Set up the code for the BeforeUpdate event of the form (not of a
control), like this:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Not mbAllowSave Then
Cancel = True
MsgBox "Hit the save or cancel button."
End If
End Sub
 

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