I have this code on the first textbox on a userform
The problem I am having is because the focus is set to begin in this textbox after I send a record to excel, it generates the msgbox before the user has a chance to enter any data.
The same thing happens if the user clicks the little x in the corner of the form if the cursor is in this textbox at the time.
Is there a way to prevent this from happening?
Code:
Private Sub Textbox1_AfterUpdate()
If Not Textbox1.Value Like "*[ ]*" Then
MsgBox "Must include both First & Second Name"
Cancel = True
Textbox1.SetFocus
End If
End Sub
The problem I am having is because the focus is set to begin in this textbox after I send a record to excel, it generates the msgbox before the user has a chance to enter any data.
The same thing happens if the user clicks the little x in the corner of the form if the cursor is in this textbox at the time.
Is there a way to prevent this from happening?