G
Guest
Here is my code:
'Create variables with short names
Dim a, b As Control
Set a = Me.Controls("Email")
Set b = Me.Controls("Phone")
'Create array of variables
Dim aryControls(2) As Control
Dim Z as Variant
'Populate array
aryControls(1) = a <--- Error here: "Object variable or With block variable
not set" aryControls(2) = b
'Check each element in the array for being null, will eventually contain
many vars
For Each Z In aryControls
If IsNull(aryControls(1).Value) Then
MsgBox "aryControls(1) is Null"
Else
MsgBox "aryControls(1) has a value!"
End If
Next Z
How do I create an array of the control variables and then reference them in
loops?
'Create variables with short names
Dim a, b As Control
Set a = Me.Controls("Email")
Set b = Me.Controls("Phone")
'Create array of variables
Dim aryControls(2) As Control
Dim Z as Variant
'Populate array
aryControls(1) = a <--- Error here: "Object variable or With block variable
not set" aryControls(2) = b
'Check each element in the array for being null, will eventually contain
many vars
For Each Z In aryControls
If IsNull(aryControls(1).Value) Then
MsgBox "aryControls(1) is Null"
Else
MsgBox "aryControls(1) has a value!"
End If
Next Z
How do I create an array of the control variables and then reference them in
loops?