How to go to a specific TabIndexed control

Posted on 2006-03-23
Last Modified: 2012-08-13
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
Question by:Mach1pro
    LVL 46

    Expert Comment

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

    Good Luck!

    LVL 6

    Author Comment

    Your code would set the focus to the next control in the control indexes, not the next tabIndex.
    LVL 34

    Accepted Solution

    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
            End If

    Dave :-)
    LVL 44

    Expert Comment

    by:Leigh Purvis
    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.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    Suggested Solutions

    QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
    Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
    Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
    In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now