Hello,
Rather than adding 27 text boxes to a collection individually, I am trying to create a loop. However, I keep receiving numerous error messages. Is there a way I can set the variable in the loop as a string or variant, but then change the type to Control in add method line?
Here's what I have...
Dim colTxtBox As Collection, i As Integer, ctl As Control, txtRef As Variant
Set colTxtBox = New Collection
For i = 1 To 27
txtRef = "Me.Text" & i
colTxtBox.Add txtRef
Next i
For Each ctl In colTxtBox
ctl.Enabled = False
Next
Many thatnks
Rather than adding 27 text boxes to a collection individually, I am trying to create a loop. However, I keep receiving numerous error messages. Is there a way I can set the variable in the loop as a string or variant, but then change the type to Control in add method line?
Here's what I have...
Dim colTxtBox As Collection, i As Integer, ctl As Control, txtRef As Variant
Set colTxtBox = New Collection
For i = 1 To 27
txtRef = "Me.Text" & i
colTxtBox.Add txtRef
Next i
For Each ctl In colTxtBox
ctl.Enabled = False
Next
Many thatnks