Pretty new to classes.
Here's a simple class I have.
Above, I've created a collection of all labels in the header of the form, and have set a click event for each of them.
Works fine.
My Question:
How can I save the last clicked label name and show it in a msgbox?
When the form opens, the first click on any label should show a blank msgbox.
From there, if I click any label, I want the msgbox tell me what was the previous label that was clicked.
To gain this, I added the following :
and changed the onClick function to :
Even though I set the clicked label name in LastClickedLabel property, but the msgbox doesn't show the previously clicked label.
Any kind of advice is much appreciated.
A database that shows what I have is attached.
Thanks again.
Here's a simple class I have.
SQL:
Private WithEvents m_Label As Label
Private LabelCollection As Collection
'************************************************************************'
Public Sub init(frm As Access.Form)
Dim Ctrl As Control
Dim srtCtrl As clsMyClass
Set LabelCollection = New Collection
For Each Ctrl In frm.Section(acHeader).Controls
Select Case Ctrl.ControlType
Case acLabel
Set srtCtrl = New clsMyClass
Set srtCtrl.Ctrl = Ctrl
LabelCollection.Add srtCtrl
End Select
Next
End Sub
'************************************************************************'
Public Property Set Ctrl(ctl As Control)
Set m_Label = ctl
m_Label.OnClick = "[Event Procedure]"
End Property
'************************************************************************'
Private Sub m_Label_Click()
testFunction m_Label
End Sub
'************************************************************************'
Private Function testFunction(lbl As Access.Label)
MsgBox lbl.Name
End Function
'************************************************************************'
Above, I've created a collection of all labels in the header of the form, and have set a click event for each of them.
Works fine.
My Question:
How can I save the last clicked label name and show it in a msgbox?
When the form opens, the first click on any label should show a blank msgbox.
From there, if I click any label, I want the msgbox tell me what was the previous label that was clicked.
To gain this, I added the following :
SQL:
Private m_LastClickedLabel As String
Private Property Let LastClickedLabel(ByVal NewValue As String)
m_LastClickedLabel = NewValue
End Property
Private Property Get LastClickedLabel() As String
LastClickedLabel = m_LastClickedLabel
End Property
and changed the onClick function to :
SQL:
Private Function testFunction(lbl As Access.Label)
MsgBox LastClickedLabel
LastClickedLabel = lbl.Name
End Function
Even though I set the clicked label name in LastClickedLabel property, but the msgbox doesn't show the previously clicked label.
Any kind of advice is much appreciated.
A database that shows what I have is attached.
Thanks again.
Attachments
Last edited: