How to go to a specific TabIndexed control

I know the name of the control in a form  and can retrieve the tabIndex.  eg.  i = Controls("name of control").TabIndex
How can I set the focus to a specific control using the tabindex? For example I want to set focus to  i + 3
LVL 6
Mach1proAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

tbsgadiCommented:
Hi Mach1pro,
How about Controls(i+3).setfocus

Good Luck!

Gary
Mach1proAuthor Commented:
tbsgadi
Your code would set the focus to the next control in the control indexes, not the next tabIndex.
flavoCommented:
Hi Mach1pro,
This is the only way I can think of:

    Dim i As Long
    Dim c As Control
    i = Me.myControl.TabIndex

    For Each c In Me.Controls
        On Error Resume Next
        If c.TabIndex = i + 3 Then
            c.SetFocus
        End If
    Next

Dave :-)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Leigh PurvisDatabase DeveloperCommented:
You might want to check for TabStop being set to true also and count on only if that is met.

That would involve iterating through the controls at least three times!

But if you're sure it won't be then yep - Dave's way is the way.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.