Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Set Focus Problem with Multipage Control sebastienm Excel Programming 0 July 16th 04 10:20 PM
Set Focus Problem with Multipage Control sebastienm Excel Programming 0 July 16th 04 10:20 PM
Set Focus Problem for textbox control on multipage control ExcelDeveloperSPR Excel Programming 1 July 16th 04 08:54 PM
Focus on Control before UserForm(s) pop up Bob Phillips[_6_] Excel Programming 0 May 5th 04 04:03 PM
test if a control has or doesnt have focus? John T Ingato Excel Programming 0 November 11th 03 04:37 PM


All times are GMT +1. The time now is 03:54 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"