Userform

  • Thread starter Thread starter Jenny
  • Start date Start date
J

Jenny

I have a userform that a user inputs data into. I have
set up code that will give a message box if certain
conditions are not satisfied when data is entered into a
text box. When the user click OK on the msgbox, the
textbox is cleared so the proper data can be input.

If Len(txtStk.Value) <> 5 Then
MsgBox "Please Check Stock number"
txtStk.Value = ""
txtStk.SetFocus
End If

This all work fine, but the cursor moves to the next box
in the tab order. I would like to cursor to stay in the
txtStk text box. Can anyone see what I am doing wrong
and please help me.

Thank you
 
if you are using the exit event, then setting Cancel = True will cause the
cursor not to move.
 
Hi
in which event do you put this code. Normally this should work?
 
If your main purpose is to validate the entry then I would use the exit
event and take advantage of the Cancel argument.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top