Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a form with 2 controls; TextBox1 and SpinButton1. I want only
TextBox1 to ever have focus, and for SpinButton1 to do a small job, then give focus back to TextBox1. The code I have written is as follows: Option Explicit Private Sub SpinButton1_SpinDown() TextBox1.SetFocus End Sub Private Sub SpinButton1_SpinUp() TextBox1.SetFocus End Sub When I click SpinButton1, focus is sent to TextBox1 only every other time; not every time. However, when I put a breakpoint on TextBox1.SetFocus (so I have to click the 'run' arrow each time), focus is returned to TextBox1 each time as it should be. Although tabstop does not affect this effect, I do have it set to false. Setting TakeFocusOnClick to false isn't a help, because a spin button doesn't have that property, so I can't set it at all. I have placed a 'doevents' statement in each Sub, but that didn't help (Perhaps I didn't do it correctly?). How can I get it to return focus after each click to TextBox1? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() heres the reply from your other thread. it's the same thing to be done. I dont have much experience with spinbuttons, but just as a little fun, I tried to goof around with it. It's probably not 100% correct as far as correct programming format, but it gets the job done, at least on my system. Add a SpinButton1.SetFocus command before the TextBox1.SetFocus command. When you click on it, it doesnt depress like normal, but it does reset the focus after only 1 click each time. Option Explicit Private Sub SpinButton1_SpinDown() SpinButton1.SetFocus TextBox1.SetFocus End Sub Private Sub SpinButton1_SpinUp() SpinButton1.SetFocus TextBox1.SetFocus End Sub -- dok112 ------------------------------------------------------------------------ dok112's Profile: http://www.excelforum.com/member.php...o&userid=10581 View this thread: http://www.excelforum.com/showthread...hreadid=531110 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Keeping focus on a txtbox | Excel Programming | |||
Keeping The Focus From Changing. How? | Excel Programming | |||
txtbox problem | Excel Programming | |||
To put value from txtbox to cell? | Excel Programming | |||
txtbox code | Excel Programming |