Don't Close Form If...

  • Thread starter Thread starter Sash
  • Start date Start date
S

Sash

I want to build and event procedure in Close Form that says if field A is
null, don't close the form.

If IsNull(FieldA) then
MsgBox "Field A is Not Complete"
End If

But how do I then state, don't continue to close the form.
 
Check in the Unload event, not the Close event:

Private Sub Form_Unload(Cancel As Integer)

If IsNull(FieldA) then
MsgBox "Field A is Not Complete"
Cancel = True
End If

End Sub
 
I want to build and event procedure in Close Form that says if field A is
null, don't close the form.

If IsNull(FieldA) then
MsgBox "Field A is Not Complete"
End If

But how do I then state, don't continue to close the form.

Use the Form's Unload event for this:

Private Sub Form_Unload(Cancel As Integer)
If IsNull([ControlA]) Then
MsgBox "ControlA is not complete."
Me!ControlA.SetFocus
Cancel = True
End IF
End Sub
 
Back
Top