I need help figuring out a solution to a user form problem I have. I have a Text Box that requires the last 4 digits entered into that textbox to be numeric. If it is not, the field will clear and allow the user to resubmit the entry. This is currently running on the After Update Event. The problem I’m having is when the invalid entry is made, the textbox is cleared and then the form auto tabs to the next control. I’m having trouble getting the focus to stay on the textbox. I’ve also noticed that because I’m changing the textbox value to nothing (“”) in the after update event. I’m getting the msgbox to display twice. I’d like to avoid that msgbox from displaying twice. I’m using Excel 2003 and Windows XP. Below is what I’m currently using on this event. I would appreciate any help or suggestions with this. Thanks in advance.
Private Sub TextBox10_AfterUpdate()
If Right(TextBox10.Value, 4) Like “####” Then
Exit Sub ‘ The last 4 characters are all numeric, Exit the after update event.
Else
‘ The last 4 characters are not all numeric.
MsgBox (“This field requires the value to be entered in a specific format.”),vbCritical, “Invalid format”
TextBox10.Value = “”
End If
End Sub