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