Using Nested Loops : For Each « Language Basics « VBA / Excel / Access / Word






Using Nested Loops

 
Sub GetFormsAndControls() 
    Dim accObj As AccessObject 
    Dim myControl As Control 

    Set obj = CurrentProject.AllForms 

    For Each accObj In obj 
        Debug.Print accObj.Name & "---Form" 
        If Not accObj.IsLoaded Then 
            DoCmd.OpenForm accObj.Name 
           For Each myControl In Forms(accObj.Name).Controls 
                Debug.Print Chr(9) & myControl.Name 
            Next 
            DoCmd.Close 
        End If 
    Next 
End Sub 

 








Related examples in the same category

1.Using the For Each...Next Loop
2.Early Exit from a Loop
3.Loop through ranges
4.For...Each Variation
5.Looping through the elements in an array