ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   TextBox focus 2 (https://www.excelbanter.com/excel-programming/305123-textbox-focus-2-a.html)

Tim Coddington

TextBox focus 2
 
I have a userform with two option buttons and a text box.
I want to have the text box always have the focus.
If I click on an un-selected option button, I can give the
text box focus through TextBox1.Setfocus in the click
event of each option button.
But when I click on a selected option button, the click
event for that option button doesn't appear to fire, and
focus changes to the option button.
Is there some way I can keep the focus on TextBox1
for this scenario?



Tom Ogilvy

TextBox focus 2
 
On a userform? (assume so since you are using setfocus).


how about using the enter event to see if the option button is true and if
so, set the focus to the textbox.

--
Regards,
Tom Ogilvy

"Tim Coddington" wrote in message
...
I have a userform with two option buttons and a text box.
I want to have the text box always have the focus.
If I click on an un-selected option button, I can give the
text box focus through TextBox1.Setfocus in the click
event of each option button.
But when I click on a selected option button, the click
event for that option button doesn't appear to fire, and
focus changes to the option button.
Is there some way I can keep the focus on TextBox1
for this scenario?





Tim Coddington

TextBox focus 2
 
Changing my _Click events to _Enter events did help. Thanks, Tom.
There is another problem. When I am in the text box and press <cr,
(I capture it and process the info in the text box with keypress()), the
text box looses focus. I tried setting focus to TextBox1 in
TextBox1_Exit(), but then, when the form exits, an error is generated.

Any more help available?

"Tom Ogilvy" wrote in message
...
On a userform? (assume so since you are using setfocus).


how about using the enter event to see if the option button is true and if
so, set the focus to the textbox.

--
Regards,
Tom Ogilvy

"Tim Coddington" wrote in message
...
I have a userform with two option buttons and a text box.
I want to have the text box always have the focus.
If I click on an un-selected option button, I can give the
text box focus through TextBox1.Setfocus in the click
event of each option button.
But when I click on a selected option button, the click
event for that option button doesn't appear to fire, and
focus changes to the option button.
Is there some way I can keep the focus on TextBox1
for this scenario?








All times are GMT +1. The time now is 12:46 PM.

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