HI all,
I am populating a collection like so:
Code:
'Standard Module
Dim Ctl As Control ' Declare Ctl as a Control
Dim clText As Cls_Text ' Declare clText for use by the Class
Set ColTxtBox = New Collection ' Note that the collection is declared in module declarations (Mod_Example)
For Each Ctl In Me.Controls
If TypeName(Ctl) = "TextBox" Then
Set clText = New Cls_Text ' Create instance of the class
Set clText.CTxt = Ctl ' Assign the control to the class instance
clText.CTxt.OnGotFocus = "[Event Procedure]" ' Assign an event procedure to the class control
clText.CTxt.OnClick = "[Event Procedure]"
clText.CTxt.AfterUpdate = "[Event Procedure]"
ColTxtBox.Add clText, Ctl.Name ' Add the class instance to the collection
End If
Next Ctl
The purpose here is to assign a class to a series of textboxes.
Code:
'Class Module
Public WithEvents CTxt As Access.TextBox
Private Sub CTxt_Click()
CTxt.BackColor = RGB(255, 0, 0)
End Sub
All of this is working fine, however, ColTxtBox.item(number) throws an error and does not work.
Code:
Error: 438: Object doesn't support this property or method
I would like to be able to loop through each item in the collection and modify it, however, this .item error seems not to allow me to see the collection object. Why not?
Note that ColTxtBox.count does work just fine, so I know that the collection contains items.
Thanks for helps!
Cheers