Thank you both for your responses. I didn't think it through very well before I asked and find that I have to do something like the above example, which is what I wanted to avoid. The data select frame has a list f data points the user can choose from in any order he/she wants. The result of the selection is a chart with the series displayed in the order chosen from the form. So when the user clicks on Outdoor Temperature then that item should be in the array at the next available position. But instead of having a Sub for each selection I was wanting to do something like
Sub FrameDataSelect_Click()
' Which item was just selected
'Here I tried;
' Me.Controls("FrameDataSelect").Selection
'to identify the object within the frame that was selected.
'But I am not "seeing" the object correctly.
'Add that to the array
'increment the array counter
End Sub
Suppose I use labels in the frame so that when the user clicks on a label I can change the forecolor to green or gold or whatever, add a - to the Caption and the position value, i.e. "Indoor Humidity - 3" meaning that this will be the third line in the chart.
I also have a "Reset All" button that would just reset everything, but again I am having trouble accessing the objects in the way I expect.
Private Sub cmdClear_Click()
Dim ctrl As MSForms.Control
Dim thisControl As Object
For Each ctrl In Me.Controls.Item("DataSelectFrame")
If TypeName(ctrl) = "Label" Then
Me.Font.ForeColor = vbBlack
Me.Caption = Left(Me.Caption, Len(Me.Caption) - 4)
End If
Next
End Sub
I have been away for a long time. I guess I just have to get back up to speed. The object browser shows the MSForms Controls as having font etc accessible, but my code is telling me that the object doesn't support this property on the for each line. This is related to the original question in that I am trying to grab and object and manipulate its internal objects.
Bookmarks