hi, i am trying to change the properties of multiple txt boxes! if the textbox name starts with txtM then i want to change the properties to something different to the text boxes that start with txtN! the code i am using is as follows!
Dim ctlTxtBox As Control
For Each ctlTxtBox In Me.Controls.Count
With ctlTxtBox
If Left(ctlTxtBox, 4) = "txtM" Then
.BackColor = 1
ElseIf Left(ctlTxtBox, 4) = "txtN" Then
.BackColor = 2
End If
.locked = false
End With
Next ctlTxtBox
i get a compile error stating "for each may only iterate over a collection or an array"! anybody got any ideas where i am going wrong?
N
Dim ctlTxtBox As Control
For Each ctlTxtBox In Me.Controls.Count
With ctlTxtBox
If Left(ctlTxtBox, 4) = "txtM" Then
.BackColor = 1
ElseIf Left(ctlTxtBox, 4) = "txtN" Then
.BackColor = 2
End If
.locked = false
End With
Next ctlTxtBox
i get a compile error stating "for each may only iterate over a collection or an array"! anybody got any ideas where i am going wrong?
N