changing properties of multiple contols

NC73

New member
Local time
Today, 23:27
Joined
Aug 18, 2004
Messages
5
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
 
Well, I can see either no one had an answer for this or it was a thread that was damaged after the board crash/hack/whatever.

I have a similar issue, but the names on my text boxes aren't consistent. I don't understand how to use arrays to cycle through multiple textbox properties (if that is even possible). If an array is the right method then can someone point me to a layman explaination.

Otherwise, I was wondering if there was a method to set an initial textbox and do something like moveing through recordsets with movenext to change properties on different textboxes. Any help will be greatly appreciated.
 
you don't need the .Count in your first line the Me.Controls.Count
 

Users who are viewing this thread

Back
Top Bottom