0 pts.
 Reference controls by name
I need to point to a control whose name I won't know until run-time. How do I do it? My code currently looks a little like this: ======== Dim ctlControl as Control Dim strName as String ctlControl = cType(strName, Control) ...now do stuff with/to the control named strname... ======== Now this is clearly rubbish, but it illustrates what I want to do. Any ideas?

Software/Hardware used:
ASKED: April 4, 2005  12:16 PM
UPDATED: June 29, 2005  3:34 PM

Answer Wiki:
Look into FindControl() as a method to use from the container that the dynamic control is in using the ID of the created control, hopefully strName is the ID ...
Last Wiki Answer Submitted:  April 4, 2005  1:20 pm  by  Timallard   0 pts.
All Answer Wiki Contributors:  Timallard   0 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Sorry to reply so late!

Try:

.Controls.Add Type:=’type of control’, temporary:=’Boolean’
With .Controls.Count ‘new controls always at end of list
.Caption = “Something useful to you.”
.OnAction = “Some Procedure name”
.Tag = “Some identifier useful to you.”
End With

 0 pts.