Textbox

R

ranswrt

How do I get a curser to move to a textbox in a userform when a button is
clicked?
Thanks
 
J

JLGWhiz

I created a UserForm with three text boxes. Then I used the initialize event
to put the cursor in TextBox3, I used double click events in TextBox 3 and 2
to move the cursor to TextBoxes 2 and 1 respectively. Then a double click
event in TextBox1 to close the UserForm. Here is the code behind the
UserForm:

Private Sub TextBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Unload Me
End Sub

Private Sub TextBox2_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
TextBox1.SetFocus
End Sub

Private Sub TextBox3_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
TextBox2.SetFocus
End Sub

Private Sub UserForm_Initialize()
Me.TextBox3.SetFocus
End Sub

Of course, the UserForm1.Show command is issued from the standard code module.
 

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

Top