M
mscertified
My form has lots of valudations that must pass before a record can be saved.
These are coded in BeforeUpdate event. and Cancel is set for errors.
This works great when moving record to record but when the user presses the
exit button or clicks the red X in the top right corner, the form still
closes.
One of the validations is a check for referential integrity, if this check
fails but the form closes, I get the Access "Record cannot be saved" message.
How can I avoid this? I tried putting a cancel in the Form Unload event but
it does not trigger. Here is my unload event:
If (Not Me.NewRecord) And Me.Dirty Then
If Not ValidateForm() Then 'Redo form validations
Cancel = True
End If
End If
These are coded in BeforeUpdate event. and Cancel is set for errors.
This works great when moving record to record but when the user presses the
exit button or clicks the red X in the top right corner, the form still
closes.
One of the validations is a check for referential integrity, if this check
fails but the form closes, I get the Access "Record cannot be saved" message.
How can I avoid this? I tried putting a cancel in the Form Unload event but
it does not trigger. Here is my unload event:
If (Not Me.NewRecord) And Me.Dirty Then
If Not ValidateForm() Then 'Redo form validations
Cancel = True
End If
End If