[AccessD] Dirty property

Bill Benson bensonforums at gmail.com
Thu Jul 23 07:32:53 CDT 2015


This advice I just found on the web might put this whole thing to bed and
give a real solution - without getting rid of the close button.

Option Compare Database
Option Explicit
Dim mbSaving As Boolean
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim Ctrl As Control
If Not mbSaving Then
    Cancel = True
End If

End Sub


Private Sub CmdSave_Click()
    mbSaving = True
    DoCmd.RunCommand acCmdSaveRecord
    mbSaving = False
End Sub
Private Sub Form_Error(DataErr As Integer, Response As Integer)
 If DataErr = 2169 Then
    Response = acDataErrContinue
 End If
End Sub

An even more robust version here:

http://stackoverflow.com/questions/22360220/access-vba-run-time-error-2169-you-cant-save-this-record-at-this-time


More information about the AccessD mailing list