Make your own free website on Tripod.com
Access Controls By Their Names As Text Strings

In the example below, we access Command Button with the name "Command1" by the string "Command1".

Preparations

Add 1 Command Button (named Command1) to your form.
Set the Command Button caption property to "This is Command1 Caption".

Form Code

Private Sub Command1_Click()
'replace "Command1" with the String that contains the control name.
'note that if there is no control with this name, you will get an error message.

    MsgBox Controls("Command1").Caption
End Sub

Go Back