Returning focus to a user form after getting message box respo
This probably isn't very elegant: I'm a newbie. But I appreciate your offer
of help.
GoodData = False 'ensures that the loop starts
Do Until GoodData
If txtUserEmail.Value Like "*_*" Then 'checks to make
sure that the user's name is in the form "firstname_lastname"
GoodData = True
Else
If txtUserEmail.Value Like "* *" Then 'if the e-mail
address is missing the underscore
txtUserEmail.Value = LTrim(txtUserEmail.Value)
txtUserEmail.Value = Replace(txtUserEmail.Value, " ", "_")
'the program replaces a space with an underscore
GoodData = True
Else
If txtUserEmail.Value = "" Then 'if the user has not
entered a name in the text box
Dim Answer As VbMsgBoxResult
Answer = MsgBox("You have not entered your e-mail
address.", vbOKCancel)
If Answer = 2 Then
Exit Function
End If
Else
If Answer = 1 Then
txtUserEmail.SetFocus
End If
End If
End If
End If
Loop
"Mike" wrote:
Lets see your code then maybe we can help
"Capt. Bangs" wrote:
I have created a user form, and I'm at the stage where I'm programming the
data entry validation. I'm getting the message box to display when the user
hasn't enter what was expected, but then I can't get the code to return the
focus to the form itself to allow the user to correct the data entry. Any
suggestions?
Thanks!
|