Jeff Stewart said:
Well, actually, silent discarding of incomplete or unsavable records
is what I want. I'm closing the form using the standard Windows "X"
button. There must be no UI prompts if the user closes the form in
this way. Only records that have been committed via my "Commit"
button (which moves to a new record) must be put to the underlying
table.
Are you sure? Don't you think you may have users who enter data for a
record but then forget to click the Commit button?
Here's code from a form module that implements the bare bones of what
you describe, but I have serious reservations about discarding the
user's entries without warning:
'----- start of example code for form module -----
Option Compare Database
Option Explicit
Dim mfCommit As Boolean
Private Sub cmdCommit_Click()
mfCommit = True
RunCommand acCmdRecordsGoToNew
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Not mfCommit Then
Debug.Print "Not committed", Me.ID
Me.Undo
End If
End Sub
Private Sub Form_Current()
mfCommit = False
End Sub
'----- end of example code for form module -----