moving cursor to a text box

  • Thread starter Thread starter JT
  • Start date Start date
J

JT

I'm using the code below to check for the length of data a
user has entered in a text box.

Private Sub In_ExpBr_Exit(ByVal cancel As
MSForms.ReturnBoolean)

If Len(In_ExpBr) < 2 Then
MsgBox "Please enter a valid branch number."
End If

End Sub

The user enters data into 5 text boxes. This code is
attached to the 3rd text box. After they click okay, the
message box goes away and the cursor is in the 4th text
box.

What can I add so that the cursor goes back to the 3rd
text box where they fix the branch number to be 2
characters.

Thanks for the help.........
 
JT,

Try adding Cancel = True to your code before End If

Regards
Neil

Private Sub In_ExpBr_Exit(ByVal cancel As
MSForms.ReturnBoolean)

If Len(In_ExpBr) < 2 Then
MsgBox "Please enter a valid branch number."
Cancel = True
End If

End Sub
 
Back
Top