Variable for Label Name

G

Guest

Is there any way to use a 'variable' for the name of a label on a form. Such
as - if you have a form with ten labels on it named 'Label1', 'Label2', . .
.., 'Label10', is there any way to use code such as this to reference them:

for xx = 1 to 10
Label'xx' = data
next xx
 
J

Juan Pablo González

Using the Controls collection

For i = 1 to 10
Me.Controls("Label" & i).Object.Caption = "something"
Next i
 
G

Guest

Works perfectly. Thank you very much!


Juan Pablo González said:
Using the Controls collection

For i = 1 to 10
Me.Controls("Label" & i).Object.Caption = "something"
Next i
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top