Using the For Each...Next Loop : For Each « Language Basics « VBA / Excel / Access / Word






Using the For Each...Next Loop

 
   Sub GetControls() 
       Dim myControl As Control 
       Dim myForm As Form 

       DoCmd.OpenForm "Customers" 
       Set myForm = Screen.ActiveForm 

       For Each myControl In myForm 
           Debug.Print myControl.Name 
       Next 
   End Sub 

 








Related examples in the same category

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