General discussion

Locked

Specify which control gets focus in an E

By jholloway@familyandchildr ·
I'm using a Multipage userform. I want to specify which page is displayed when the form is openned and I want to specify a particular text box on that page to have the focus with all the text selected. Any help out there?

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Specify which control gets focus in an E

by MikeDale In reply to Specify which control get ...

You can set the text box the will have the focus buy using the 'Setfocus' property on the text box.

ie.
TextBox1.SetFocus

If the textbox have the focus this should display that page on the screen.

Hope this helps

Collapse -

Specify which control gets focus in an E

Thanks for your answer, Mike, but when I used SetFocus it worked for single forms, but not for multipages. After considerable trial and error, I discovered that it worked in Excel97 but not Excel 2000. As a work-around in Excel 2000, I added Application.SendKeys ("(TAB)") to move to the next textbox, then Application.SendKeys ("+(TAB)") to shift/tab back to the original textbox and that worked.

Collapse -

Specify which control gets focus in an E

by francodacosta In reply to Specify which control get ...

try setting the TabIndex property of the control to 0.

When a window is opened the control with TabIndex=0 always get the focus.

Collapse -

Specify which control gets focus in an E

Actually, I didn't find this technique to work, but I like the idea and I'm going to play with it later. I think the reason might be that I have controls on the main form plus I have 2 multipage form pages on that same main form. I want the initial focus on the first control on the first multipage. I got that result by coding in a TAB then a Reverse TAB upon activating the form. However, I'm going to try your idea to see if the TAB order can be improved for people Tabbing through. Thanks.

Collapse -

Specify which control gets focus in an E

This question was closed by the author

Back to Windows Forum
5 total posts (Page 1 of 1)  

Related Discussions

Related Forums