Relocate Tab Position via Code?

Rufus Clupea

Board Regular
Joined
Feb 11, 2019
Messages
85
Related to my second question in a previous thread:
Is there a way to tab (key) directly from the last TabStop on one page of the MultiPage to the first TabStop on the next page without manually clicking on the MultiPage tab and the first TabStop on each subsequent page?
Is there any way to change the tab position via VBA code? Here's the situation:

I have a Frame containing 8 OptionButtons and 1 SpinButton/Label combination.
If the SpinButton is clicked, the OptionButtons are all "zeroed out" (.Value = False) and the SpinButton does its thing.

If one of the OptionButtons is subsequently clicked, the SpinButton is zeroed out, and the OptionButtons do their thing.

This all works, but the tab position remains on the SpinButton, which could be confusing to an uninitiated User. (At a size of 10 x 18, the SpinButton is rather small; large enough to manipulate by mouse or keyboard, but small enough that the tab position highlight could be missed.)

I'd like to move it (have it automatically move) to the subsequently chosen OptionButton, so the TabStop progression can then continue normally.

Anyone know any way this can be done via code?

TIA
 

Some videos you may like

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

igold

Well-known Member
Joined
Jul 8, 2014
Messages
2,503
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Why don't you just set the focus to the object that you want as part of the code that was just executed, and from there the TabIndex order will takeover. Something like this...

Code:
Me.ListBox2.SetFocus
 

Rufus Clupea

Board Regular
Joined
Feb 11, 2019
Messages
85
Umm.. because I don't know enough to know what that means yet? :LOL:

I'll try it; thanks for the suggestion! :)
 

Rufus Clupea

Board Regular
Joined
Feb 11, 2019
Messages
85
(A few minutes later...)

Yes, that seems to work. Took me a few to learn about SetFocus; it's not listed as an object property (I spoze because it's a method—still not comfortably clear with the difference(s)), it's not in either of my VBA books, and deciphering MS Docs seems to require a degree in Rocket Science/Brain Surgery...

But I got there! :cool:

Thanks again!
 

igold

Well-known Member
Joined
Jul 8, 2014
Messages
2,503
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Happy to help, I am glad it worked for you. I actually learned it when I was teaching myself Access.

Thanks for the feedback!
 

Watch MrExcel Video

Forum statistics

Threads
1,108,970
Messages
5,525,965
Members
409,673
Latest member
Riseee

This Week's Hot Topics

Top