ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Set focus to textbox after spin-button control is pressed?? (https://www.excelbanter.com/excel-programming/437865-re-set-focus-textbox-after-spin-button-control-pressed.html)

Homey

Set focus to textbox after spin-button control is pressed??
 
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.


"Robert Crandal" wrote in message
...
| 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
|
|


Robert Crandal

Set focus to textbox after spin-button control is pressed??
 
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!




"Homey" <none wrote in message
...
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.





All times are GMT +1. The time now is 11:40 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com