Hi,
Just adding without ignoring Tom's code:
Private Sub CommandButton1_Click()
If TextBox1 = "" Then TextBox1.SetFocus: Exit Sub
Unload Me
End Sub
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If TextBox1 = "" Then Cancel = True
End Sub
--
Regards,
Halim
"LuisE" wrote:
> I’ve been trying to write a routine to prevent empty textboxes. I’m using the
> TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) event. But since I
> disabled the close button and using a CommandButton instead; if the user
> doesn’t make any entry at all, it’ll still trigger the error message when
> closing the form. Is there a way around it. Can I cancel the “cancel event”
> while closing the form from the CommandButton?
>
> I can’t retain the focus on the control. I also tried the BeforeUpdate event
> but didn’t get the expected results. Do you know of any good source of
> related documentation?
>
>
>
>
|