XL-2003 - Class Module - Controls declared "withEvents" don't sink events..
Thanks !
Obviously it's monday morning ! ;-)
This is the way I always did it in Access ; Bob Phillips shows another
method using a controls collection I didn't knew about.
Is there actually a difference between these methods in terms of
performance, readability, upward compatibility ?
Thanks again !
PS: I saw your replies in Google groups *before* they even show in my
newsreader - even with a refresh every five minutes - really amazing !
Andy Pope avait soumis l'idée :
Hi,
By using Dim in the userform initialize event you are actual creating an
instance local to that procedure rather than the instance to the userform.
Try this modification.
Private Sub UserForm_Initialize()
Set objBtn = New clsBtn
Set objBtn.Ok = Me.ExistingCmdBtnOnThisForm
End Sub
Cheers
Andy
Michel S. wrote:
Hello !
Given the following code :
' == clsBtn Class module
Private WithEvents mCmdOk AS MSForms.CommandButton
Public Property Set Ok (cmd AS MSForms.CommandButton)
Set mCmdOk = cmd
End Property
Private Sub mCmdOk_Click()
MsgBox "Ok button clicked"
End Sub
' == User Form
Private objBtn AS clsBtn
Private Sub UserForm_Initialize
Dim objBtn as New clsBtn
Set objBtn.Ok = Me.ExistingCmdBtnOnThisForm
End Sub
When I click on "Me.ExistingCmdBtnOnThisForm", I expect the MsgBox to pop,
but nothing happens.
Any idea why it doesn't work ?
Thanks
|