ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Keeping focus on a txtbox (https://www.excelbanter.com/excel-programming/358049-keeping-focus-txtbox.html)

Tim[_44_]

Keeping focus on a txtbox
 
I have txt1 on a form which should always get focus after any other
control is used. I have a spin button which I use to change the value
in txt2. When I click the spin button, if I use txt1.setfocus at the
end of the spinup and spindown events, txt1 only receives the focus
every second click. Why is this? The only way I have found to keep
the focus on txt1 is by placing the txt1.setfocus in the 'enter' event,
but then the spin button has no effect. How can I keep the focus on
txt1 and still allow the spin button to have an effect?


Jean-Yves[_2_]

Keeping focus on a txtbox
 
Hi Tim,

Give all other control the property "TabStop" to false for text boxes or
TakeFocusOnClick for button, etc to false
That way only your Text1 can get the focus
Regards
Jean-Yves

"Tim" wrote in message
ups.com...
I have txt1 on a form which should always get focus after any other
control is used. I have a spin button which I use to change the value
in txt2. When I click the spin button, if I use txt1.setfocus at the
end of the spinup and spindown events, txt1 only receives the focus
every second click. Why is this? The only way I have found to keep
the focus on txt1 is by placing the txt1.setfocus in the 'enter' event,
but then the spin button has no effect. How can I keep the focus on
txt1 and still allow the spin button to have an effect?




Tim[_44_]

Keeping focus on a txtbox
 
All controls have the tabstop set to false except Text1.
Thanks for the info on TakeFocusOnClick, but it doesn't help for a
spinner. I still have the same problem.

-Tim


Jean-Yves[_2_]

Keeping focus on a txtbox
 
Hi Tim,

Yes, just tried it ...
Then you have to give focus to the textbox by code at the end of you spinner
code
Regards
JY

"Tim" wrote in message
oups.com...
All controls have the tabstop set to false except Text1.
Thanks for the info on TakeFocusOnClick, but it doesn't help for a
spinner. I still have the same problem.

-Tim




Tim[_44_]

Keeping focus on a txtbox
 
I already do. Tried one other thing; a breakpoint on the .setfocus to
see if the event was actually occuring. It was. The extra pause given
by stopping at the breakpoint allowed the system to work as expected.
But when I remove the breakpoint, the same problem is back. Any more
ideas?



All times are GMT +1. The time now is 04:00 AM.

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