Hi,
I am trying to sink the events of 42 command buttons on one form. I have created the class clsCustomCommandButton
and have the following code in my form
But it doesnt work, can anyone assist?
Thanks
I am trying to sink the events of 42 command buttons on one form. I have created the class clsCustomCommandButton
Code:
Option Compare Database
Private WithEvents mCommandButton As CommandButton
Public Property Set CommandButon(ByVal oCommandButton As CommandButton)
Set mCommandButton = oCommandButton
End Property
Private Sub mCommandButton_Click()
MsgBox "Working"
End Sub
and have the following code in my form
Code:
Option Compare Database
Private EVENT_HANDLERS As Collection
Private Sub Form_Load()
Set EVENT_HANDLERS = New Collection
Dim oControl As Control
For Each oControl In Me.Controls
If oControl.ControlType = acCommandButton Then
Dim oEventHandler As CustomCommandButton
Set oEventHandler = New CustomCommandButton
Set oEventHandler.CommandButon = oControl
EVENT_HANDLERS.Add oEventHandler
End If
Next oControl
End Sub
But it doesnt work, can anyone assist?
Thanks