• Set Focus to specific tab on a Tab Control

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Set Focus to specific tab on a Tab Control

    Author
    Topic
    #463365

    Is it possible to set the focus on a specific tab on a tab control via VBA? My goal is to set the focus to the tab when the form opens.

    Different iterations of Me.TabCtl0.Pages.Page1.SetFocus doesn’t work. I am unable to find the correct syntax to reference the tab.

    Thanks in advance for your ideas.

    Ken

    Viewing 0 reply threads
    Author
    Replies
    • #1182635

      You have to set the Value of the tab control. The value is the zero-based index of the active tab page. Setting it to 0 activates the first page, setting it to 1 activates the second page, etc.

      So if you want to set focus to the fourth tab page, you’d use

      Me.TabCtl0.Value = 3

      • #1182636

        You have to set the Value of the tab control. The value is the zero-based index of the active tab page. Setting it to 0 activates the first page, setting it to 1 activates the second page, etc.

        So if you want to set focus to the fourth tab page, you’d use

        Me.TabCtl0.Value = 3

        Thanks Hans.

        Where do you find documentation for things like that?

        Having asked that, using the above sets the focus on the first control on the tab. I am trying to actually get the tab itself to have the focus and not the first field on the tab. Is that possible?

        Thanks for your help.

        Ken

        • #1182639

          > Where do you find documentation for things like that?

          In the Access VBA help.

          > I am trying to actually get the tab itself to have the focus and not the first field on the tab. Is that possible?

          Don’t think so.

          • #1182640

            > Where do you find documentation for things like that?

            In the Access VBA help.

            > I am trying to actually get the tab itself to have the focus and not the first field on the tab. Is that possible?

            Don’t think so.

            Hans,

            Using the Me.TabCtl0.Value = 3 in the on open event, I can hit Control Tab once the form opens and the tab is highlighted/has the focus. Is there a way to send shift tab after the Me.TabCtl0.Value = 3?

            Sorry to be so dense.

            Thanks,

            Ken

            • #1182644

              Although I can’t imagine why you would want this, you could use

              SendKeys “+{TAB}”

          • #1182643

            > Where do you find documentation for things like that?

            In the Access VBA help.

            > I am trying to actually get the tab itself to have the focus and not the first field on the tab. Is that possible?

            Don’t think so.

            Hans,

            I tried setting the focus to a control on the form header, then Me.TabCtl0.Value = 3. Voila’, I get the results I want. I don’t know why, but it works.

            THANK YOU for putting me on the right path.

            Ken

    Viewing 0 reply threads
    Reply To: Set Focus to specific tab on a Tab Control

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: