Link to home
Start Free TrialLog in
Avatar of Biggles1
Biggles1Flag for United States of America

asked on

Change label captions in Access VBA SEQUENTIALLY

I have a form with labels called lbl1, lbl2, lbl3 ....... lbl60

I want to write code that will refer to each label in turn and change the caption.

This code does NOT work:
Dim X as Integer

For X = 1 to 60
   Me.lbl & X & .Caption = "X"
Next X

I DON'T want to write 60 lines of code like this:
Me.lbl1.Caption = "1"
Me.lbl2.Caption = "2"
Me.lbl3.Caption = "3"
.....
Me.lbl60.Caption = "60"

Any Ideas what I am doing wrong?

Thanks,

Biggles1
ASKER CERTIFIED SOLUTION
Avatar of Dale Fye
Dale Fye
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Biggles1

ASKER

Thanks everyone.  Worked like a charm! (what was I thinking?)

Biggles