Full Version: Tab Focus
UtterAccess Forums > Microsoft® Access > Access Forms
tbpowers
I have an individual form with several tabs. How do I set the cursor to the first item on each tab when it is selected?
datAdrenaline
You can use the Tab Controls OnChange event and set up a Select .. Case statement ...
!--c1-->
CODE
Private Sub tabTabControlName_Change()
    Select Case Me.tabTabControlName.Value
        Case Me.pgATabPageName.PageIndex
            Me.SomeControl.SetFocus
        Case Me.pgAnothorTabPageName.PageIndex
            Me.SomeOtherControl.SetFocus
    End Select
End Sub

Also, it may be important to note that ..
- A Page's OnClick event will only fire if you click in the space that is designated for controls on that page AND transparency if OFF!
- A TabControls' OnClick event fires when you click on the tab control itself (not a page) ... for example the "grey" space to the right of the right most tab of a "standard" looking tab
Those two reasons are why the OnChange event is the appropriate choice for this sort of thing ..
tbpowers
Thank you.
tbpowers
Ok, I'm a newbie to Access so bear with me. How do I put this together? Here are the names of my tabs.
ab Controll Name = TabCtl8
Tab 1 = Data
Tab 2 = Disposition
Tab 3 = Rework Instructions
Tab 4 = Freight
tbpowers
I figured it out. Thank you for the code.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.