Stop a Form from Closing

  • Thread starter Thread starter Aaron
  • Start date Start date
A

Aaron

Hi!

I would like to find a way to prevent a form from closing
if the user leaves a textbox blank. Is there anyway to
get the Form_Close() procedure from not completing if
certain criteria are met???

Thanks in Advance!
Aaron
 
Aaron said:
I would like to find a way to prevent a form from closing
if the user leaves a textbox blank. Is there anyway to
get the Form_Close() procedure from not completing if
certain criteria are met???


The Unload event has a Cancel argument
 
Hi!

I would like to find a way to prevent a form from closing
if the user leaves a textbox blank. Is there anyway to
get the Form_Close() procedure from not completing if
certain criteria are met???

Thanks in Advance!
Aaron

Try the form's Unload event. It, unlike the Close even, can be
cancelled.

Also, you might think about using the form's before update event -
since we are talking about data validation.

- Jim
 
Yes in the Unload Event of the form

Private Sub Form_Unload(Cancel As Integer)
If (Not len(MyTextBox)) Then
Cancel = True
End If
End Sub

Where MyTextBox is the text box to test for emptiness.

Hedi
 
Thanks for the quick response. The event still completed
even though the textbox was null I also tried

If isnull(password) then
Cancel = True
end if

and

If Len(password)<0 then
Cancel =True
end if

Any thoughts/ideas? Thank you very very much!
 
Back
Top