Set focus to textbox after spin-button control is pressed??

  • Thread starter Thread starter Robert Crandal
  • Start date Start date
R

Robert Crandal

My userform contains one Textbox and one vertical Spinbutton control.
If someone presses either the spin-up or spin-down button, I want
the input focus to immediately change from the spinbutton to the
textbox control. I tried using the code below:

Private Sub SpinButton1_SpinDown()
UserForm1.TextBox1.SetFocus
End Sub

Private Sub SpinButton1_SpinUp()
UserForm1.TextBox1.SetFocus
End Sub


I thought the code above would be sufficient, but sometimes when
I press either spin button the focus does not change immediately
to the textbox control. It seems like the user has to press the same
spin button twice just to change the focus.

Does anybody know how to set this up so that if any spin button
is pressed the focus will immediately leave the spinbutton and go
somewhere else (i.e to the textbox control)

thank you
 
I try this an have same problem. it seem that where focus is at click
control where focus go. if focus on spinner then focis go to textbox. but
if focus on text box it go to spinner. i think what happen is actually
click on spinner set focus to spinner after code set it to text box. i not
find a answer that work all the time.


| My userform contains one Textbox and one vertical Spinbutton control.
| If someone presses either the spin-up or spin-down button, I want
| the input focus to immediately change from the spinbutton to the
| textbox control. I tried using the code below:
|
| Private Sub SpinButton1_SpinDown()
| UserForm1.TextBox1.SetFocus
| End Sub
|
| Private Sub SpinButton1_SpinUp()
| UserForm1.TextBox1.SetFocus
| End Sub
|
|
| I thought the code above would be sufficient, but sometimes when
| I press either spin button the focus does not change immediately
| to the textbox control. It seems like the user has to press the same
| spin button twice just to change the focus.
|
| Does anybody know how to set this up so that if any spin button
| is pressed the focus will immediately leave the spinbutton and go
| somewhere else (i.e to the textbox control)
|
| thank you
|
|
 
I found a solution that worked for me.....

I simply used 2 command buttons to act as spin-up and spin-down
controls. I put an image of an up and down arrow on each button
just to make them look like an actual spin control!
 
Back
Top