Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.
One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.
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
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.