Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
SpinButton control and focus
Hi all,
I have a UserForm with a number of SpinButton controls which increase or decrease the value in associated text boxes. Everything works fine, but to tidy up the display a little, I want to make sure the focus is changed to the text box, and not rest with the SipnButton. Using the .SetFocus method appears to only work every other time the SpinButton is changed. Is there something I'm missing here? Code is as follows: Sub SpinBn1_Change With TextBx1 .Value = SpinBn1.Value .SetFocus End With End Sub Many thanks in advance M@ |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
SpinButton control and focus
If you add a line of code to see where the focus is:
.SetFocus Debug.Print UserForm1.ActiveControl.Name you should see that the textbox does in fact have the focus when its value changes (open the Debug window so you can see this). I think what's happening is that the click on the spinner has not yet transferred focus to the spinner at this point. You'll note that the click that fails is the one that occurs when the textbox already has the focus. I don't know that you can change this behavior though; I couldn't find a way. -- Jim Rech Excel MVP "Matt Dalkie" wrote in message om... | Hi all, | | I have a UserForm with a number of SpinButton controls which increase | or decrease the value in associated text boxes. Everything works | fine, but to tidy up the display a little, I want to make sure the | focus is changed to the text box, and not rest with the SipnButton. | Using the .SetFocus method appears to only work every other time the | SpinButton is changed. Is there something I'm missing here? | | Code is as follows: | | Sub SpinBn1_Change | With TextBx1 | .Value = SpinBn1.Value | .SetFocus | End With | End Sub | | Many thanks in advance | | M@ |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
SpinButton control and focus
Hi Jim,
Thanks for the quick reply, and you put me onto a workaround... Set the focus onto the spinbutton as the first line of the change event. It works in terms of making the user interface tidy, until you reach either the lower or upper limit, in which case, the focus stays on the spinbutton. M@ "Jim Rech" wrote in message ... If you add a line of code to see where the focus is: .SetFocus Debug.Print UserForm1.ActiveControl.Name you should see that the textbox does in fact have the focus when its value changes (open the Debug window so you can see this). I think what's happening is that the click on the spinner has not yet transferred focus to the spinner at this point. You'll note that the click that fails is the one that occurs when the textbox already has the focus. I don't know that you can change this behavior though; I couldn't find a way. -- Jim Rech Excel MVP "Matt Dalkie" wrote in message om... | Hi all, | | I have a UserForm with a number of SpinButton controls which increase | or decrease the value in associated text boxes. Everything works | fine, but to tidy up the display a little, I want to make sure the | focus is changed to the text box, and not rest with the SipnButton. | Using the .SetFocus method appears to only work every other time the | SpinButton is changed. Is there something I'm missing here? | | Code is as follows: | | Sub SpinBn1_Change | With TextBx1 | .Value = SpinBn1.Value | .SetFocus | End With | End Sub | | Many thanks in advance | | M@ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Set Focus Problem with Multipage Control | Excel Programming | |||
Set Focus Problem with Multipage Control | Excel Programming | |||
Set Focus Problem for textbox control on multipage control | Excel Programming | |||
Focus on Control before UserForm(s) pop up | Excel Programming | |||
test if a control has or doesnt have focus? | Excel Programming |