View Full Version : Supressing error code 2619


lution
10-01-2007, 07:42 PM
I have a required property and when the use exits the form, I want to give them the choice of returning to the form and adding a value or continuing to close. I also want to supress the standard dialog for warning the user about discarding their changes.

Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim intDiscard As Integer

If IsNull(Me.Citation) Then
intDiscard = MsgBox("Discard the record because the citation number is blank?", vbYesNo)
If (intDiscard = vbYes) Then
Cancel = False
Else
Cancel = True
End If
End If

End Sub

Private Sub Form_Error(DataErr As Integer, Response As Integer)
If DataErr = 2169 Then Response = acDataErrContinue
End Sub

However, it always exists the form regardless of what the user selects for the "Discard" message box. Could someone help me with my logic?

boblarson
10-01-2007, 07:45 PM
If someone CLOSES the form, you can't cancel that close from the BeforeUpdate event. You would need to capture it in the On UNLOAD event.

lution
10-02-2007, 04:56 PM
But if the record is dirty, by the time the UNLOAD event fires, any changes the user made will be discarded because the required cell doesn't have a value so I thought I needed to ask the user about discarding in UNLOAD.