HandsOn Using the For Each Next Loop

1. Ensure that the Customers form is open in Form view.

2. Switch to the Visual Basic Editor window and insert a new module.

3. In the Code window, type the GetControls procedure as shown below.

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

4. Run the GetControls procedure by choosing Run | Run Sub/UserForm.

5. To see the results of the procedure you just executed, press Ctrl+G to open the Immediate window or choose View | Immediate Window.

Introduction to Access 2003 VBA Programming

0 0

Post a comment