Hello All,
I have created one user form which contains two combo boxes one frame called frame1 and one command button. Inside Fram1, I have 42 labels which are named from Label1 to Label42. From drop down of combo box, I select month and year. Based on these two values, caption of the label will change. I am using following code to change the caption of the lable.
However code gives me following error and does not change label caption. I understand that label cannot be viewed from user form. Above code is in user form initialize event level.
Please help to access the label which is under Frame1 which is under UserForm1
Thanks
Angsuman
I have created one user form which contains two combo boxes one frame called frame1 and one command button. Inside Fram1, I have 42 labels which are named from Label1 to Label42. From drop down of combo box, I select month and year. Based on these two values, caption of the label will change. I am using following code to change the caption of the lable.
HTML:
Dim i As Integer Dim labelCount As Integer Dim k As Integer Dim lblName As String
For i = 1 To labelCount lblName = "Label" & CStr(i) Me.Controls(lblName).Caption = k k = k + 1 Next
However code gives me following error and does not change label caption. I understand that label cannot be viewed from user form. Above code is in user form initialize event level.
HTML:
Run-time Error -2147024809 (80070057)
Could not find the specified object
Please help to access the label which is under Frame1 which is under UserForm1
Thanks
Angsuman