Howdy,
In the past I've used a Class Module in order to create change events for comboboxes which were programmatically created. I would like to use this same process to create a click event for OptionButtons which are programmatically created.
Here's what I've done so far. The error occurrs at the bolded line. It returns a Run-time error '13', Type Mismatch.
Here's the class module:
What part is incorrect in the code? Obiviously I'm not seeing why it won't work.
In the past I've used a Class Module in order to create change events for comboboxes which were programmatically created. I would like to use this same process to create a click event for OptionButtons which are programmatically created.
Here's what I've done so far. The error occurrs at the bolded line. It returns a Run-time error '13', Type Mismatch.
Code:
Private ppOps As New Collection
Private ctlOps As ppCB
Private WithEvents ppOpBut1 As MSForms.OptionButton
Private WithEvents ppOpBut2 As MSForms.OptionButton
Set ctlOps = New ppCB
[b]ctlOps.Init ppOpBut1, Me[/b]
ppOps.Add ctlOps
Set ctlOps = New ppCB
ctlOps.Init ppOpBut2, Me
ppOps.Add ctlOps
ppOps.Add ppOpBut1
ppOps.Add ppOpBut2
Here's the class module:
Code:
Option Explicit
Private WithEvents m_OB As MSForms.OptionButton
Private m_Form As Summary_Final
Public Sub Init(ctl As OptionButton, frm As Summary_Final)
Set m_OB = ctl
Set m_Form = frm
End Sub
Private Sub m_OB_Click()
m_Form.Opt m_OB
End Sub
Private Sub Class_Terminate()
Set m_OB = Nothing
Set m_Form = Nothing
End Sub
What part is incorrect in the code? Obiviously I'm not seeing why it won't work.