in the code module of the UserForm (DatePicker - no relation of the Excel form by the same name)
Public WithEvents CalBtn As MSForms.Label Public pParent As DatePicker Public Property Get Parent() As DatePicker Set CalForm = pParent End Property Public Property Set CalForm(CalForm As DatePicker) Set pParent = CalForm End Property Private Sub CalBtn_Click() MsgBox CalBtn.Name & " was clicked." Debug.Print CalBtn.Parent.Name ' DOESN'T WORK End Sub
The code runs and works without the Parent property idea. What am I doing wrong, and how to do it right?
Dim Btn() As CalButton Private Sub AssignCalButtons() ' assign all day button to CalButton class Dim Ctl As Object Dim i As Long ReDim Btn(1 To Me.Controls.Count) For Each Ctl In Me.Controls If InStr(1, Ctl.Name, "Day", vbTextCompare) = 1 Then i = i + 1 Set Btn(i) = New CalButton Set Btn(i).CalBtn = Ctl Set Btn(i).Parent = Me ' Compile error: Invalid use of property End If Next Ctl ReDim Preserve Btn(1 To i) End Sub
|Windows Service to Receive TCP Packets||4||118|
|Adoquery sql left join does not work||25||80|
|How to obtain Administrator permission when you are the Administrator||6||58|
|Create Excel formula on dynamic data||5||32|
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
14 Experts available now in Live!