I'd like to see a group example myself, Keith. I didn't know you could use that for a control array.
In the meantime here is how I would do it without getting too complex:
1. Create a class that uses the checkbox variable using withevents.
2. push the click event inside the class
3. Create a collection class to manipulate (add, delete) your controls as they are added, etc.
4. In your form code, add as you need.
5. If you need specific control (say to sync the database with the particular row your clicking) add a property to the class to keep track of which one is being clicked. I like the tab property myself.
I threw together a quick demo;
The cCheck class:
' Class cCheck
' Class to encapsulate the check box events
Option Explicit
Private WithEvents mvarmCheck As CheckBox 'local copy
Public Property Set mCheck(ByVal vData As CheckBox)
'used when assigning an Object to the property, on the left side of a Set statement.
'Syntax: Set x.mCheck = Form1
Set mvarmCheck = vData
End Property
Public Property Get mCheck() As CheckBox
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.mCheck
Set mCheck = mvarmCheck
End Property
' Here is where you do your stuff
Private Sub mvarmCheck_Click()
MsgBox "The Click Event Inside the Class Module"
End Sub
The collection class (just a class):
cChecks
' Collection Class: cChecks
' used to hold the cCheck objects
Option Explicit
'local variable to hold collection
Private mCol As Collection
Public Function Add(mCheck As CheckBox, Optional sKey As String) As cCheck
'create a new object
Dim objNewMember As cCheck
Set objNewMember = New cCheck
'set the properties passed into the method
If IsObject(mCheck) Then
Set objNewMember.mCheck = mCheck
Else
objNewMember.mCheck = mCheck
End If
If Len(sKey) = 0 Then
mCol.Add objNewMember
Else
mCol.Add objNewMember, sKey
End If
'return the object created
Set Add = objNewMember
Set objNewMember = Nothing
End Function
Public Property Get Item(vntIndexKey As Variant) As cCheck
'used when referencing an element in the collection
'vntIndexKey contains either the Index or Key to the collection,
'this is why it is declared as a Variant
'Syntax: Set foo = x.Item(xyz) or Set foo = x.Item(5)
Set Item = mCol(vntIndexKey)
End Property
Public Property Get Count() As Long
'used when retrieving the number of elements in the
'collection. Syntax: Debug.Print x.Count
Count = mCol.Count
End Property
Public Sub Remove(vntIndexKey As Variant)
'used when removing an element from the collection
'vntIndexKey contains either the Index or Key, which is why
'it is declared as a Variant
'Syntax: x.Remove(xyz)
mCol.Remove vntIndexKey
End Sub
Public Property Get NewEnum() As IUnknown
'this property allows you to enumerate
'this collection with the For...Each syntax
Set NewEnum = mCol.[_NewEnum]
End Property
Private Sub Class_Initialize()
'creates the collection when this class is created
Set mCol = New Collection
End Sub
Private Sub Class_Terminate()
'destroys collection when this class is terminated
Set mCol = Nothing
End Sub
The user form code:
' UserForm1
Option Explicit
' NOTE: Scope is important
Private ochecks As cChecks
Private oCheck As cCheck
' add the checkboxes and push to the collection class
Private Sub UserForm_Activate()
Set ochecks = New cChecks
Dim oChk As CheckBox
Set oChk = Me.Controls.Add("Forms.Checkbox.1", "MyTestCheck", True)
Call ochecks.Add(oChk, "1")
Set oChk = Me.Controls.Add("Forms.Checkbox.1", "MyTestCheck1", True)
oChk.top = 50
Call ochecks.Add(oChk, "2")
End Sub
Lotta code, but not rocket science and if you have visual basic, it will code most of the collection class for you.
Hope that helps..