Shawn V. Wilson
Shawn V. Wilson

Reputation: 1111

How to cycle between tabs on a tab?

My Access form "frmLoad" has five tabbed pages. One of those pages has a subform "frmClients" with a few dozen tabbed pages.

I need to cycle through each tabbed page on frmClients, Debug.Print the tab name, modify certain labels, and go on to the next.

(I don't have to access any other tabs on frmLoad; I only mention it in case we have to fully qualify everything.)

The documentation I've been reading is confusing. I'm not sure of the difference between a Page and a Tab, for one thing.

Upvotes: 0

Views: 50

Answers (1)

user6432984
user6432984

Reputation:

You can reference the Tab Pages from the frmClients' Controls collection.


Run this in a standard Module and it will Debug.Print the needed references.

Sub PrintLabelsReferences()
    Dim ctrl As Object, pageCtrl As Object
    For Each ctrl In Forms("frmLoad").Controls("frmClients").Controls
        If TypeName(ctrl) = "Page" Then
            For Each pageCtrl In ctrl.Controls
                If TypeName(pageCtrl) = "Label" Then
                    Debug.Print "Me.Controls(""frmClients"").Controls("""; pageCtrl.Name; """).Caption ="""; pageCtrl.Caption; """"
                    Debug.Print "Forms(""frmLoad"").Controls(""frmClients"").Controls("""; pageCtrl.Name; """).Caption ="""; pageCtrl.Caption; """"
                End If
            Next
        End If
    Next
End Sub

Uses the Forms() reference if you want to modify the Label.Caption from outside of the form or use Me if you want to reference the Label.Caption from within the Form's code module.

enter image description here enter image description here

Upvotes: 2

Related Questions