set focus...is it really this difficult?

RAYLWARD102

Well-known Member
Joined
May 27, 2010
Messages
529
I've run into this before and it drives me nuts! I have a userform with many textboxes, buttons and labels on it.
If I select all of these objects and set the tab stop to "false", and then only click on textbox1 and select tab stop = "true"; shouldn't i be able to add a line to the ending code of every button like, "textbox1.setfocus" to return the focus to the textbox1 field?
Apparently not! This blows me away!
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
I generally use:

<font face=Calibri>    <SPAN style="color:#00007F">With</SPAN> Me.TextBox1<br>        .SetFocus<br>        .SelStart = 0<br>    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

HTH,
 
Upvote 0
That works - try to type away - maybe you have some other code that moves it after you setfocus - so if you type you can see where your cursor migrated to.
 
Upvote 0
I generally avoid SetFocus, because invariably it doesn't work - kind of like SendKeys I suppose.

Using it get's particularly flaky when you involve frames, multitabs etc.:)

What is it you are trying to do?
 
Upvote 0

Forum statistics

Threads
1,224,597
Messages
6,179,808
Members
452,944
Latest member
2558216095

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top