Hello,
I stumbled across the following problem.
I have a Form with 3 Labels on it, created within Designer Mode.
Let's call them Lbl1, Lbl2, Lbl3.
Additionally, I created a class module "clsLbls" which code is:
Going back to the Form.
I want the above class module to be assigned to Labels mentioned previously. Which I tried by:
In result only first of three labels has On Click event or caption changed.
I tried the similar code in Excel and everything works like a charm (just changed Label to msForms.Label). Could you please give me an idea of how do I suppose to code it?
I stumbled across the following problem.
I have a Form with 3 Labels on it, created within Designer Mode.
Let's call them Lbl1, Lbl2, Lbl3.
Additionally, I created a class module "clsLbls" which code is:
Code:
'>>>>
Option Compare Database
Option Explicit
Public WithEvents lblTask As Label
Private Sub lblTask_Click()
lblTask.Caption = "qq"
MsgBox lblTask.Name
End Sub
Going back to the Form.
I want the above class module to be assigned to Labels mentioned previously. Which I tried by:
Code:
Private clsLblClick(1 To 3) As New clsLbls
Private Sub Form_Load()
Dim i As Integer
Dim lblThis As Label
'add class to labels for click event handling
For i = 1 To 3
Set lblThis = Me.Controls("Lbl" & i)
Set clsLblClick(i).lblTask = lblThis
Next i
End Sub
In result only first of three labels has On Click event or caption changed.
I tried the similar code in Excel and everything works like a charm (just changed Label to msForms.Label). Could you please give me an idea of how do I suppose to code it?
Last edited: