Heatshiver
Registered User.
- Local time
- Tomorrow, 04:46
- Joined
- Dec 23, 2011
- Messages
- 263
I'm trying to understand how I can make an Array and For Each statement work together. I normally don't use either, but it would be good so I could write less code where plausible. Here is the example I have:
I am unsure how I include the array in this statement. I have tried replacing "Me.Controls" with the array name, but I get a 424 runtime error (no object). What I am trying to accomplish is for each item in the array I want to make it not visible if it has a null value.
Thanks!
Code:
Dim Named As Variant
Dim Ctl As Control
Named = Array(Me.Namee, Me.ID, Me.Title)
For Each Ctl In Me.Controls
If TypeOf Ctl Is TextBox Then
If Len(Ctl) = 0 Then
With Ctl
.Visible = False
End With
End If
End If
Next
Thanks!