Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing Label Names with Code?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I was wondering if I could use VBA to change the name of a label on a form. For example, I have 20 labels named Label1, Label2, Label3,... and so on. Is there a way that I can use something like:

Dim lbl As Label
For num = 0 To 20
lbl.Name = "Label" & num
lbl.Caption = DLookup(something)
Next

I can't get it to work. Thanks.
 
Dead easy & you are nearly there:


For num = 0 To 20
me.controls("label" & num).caption=DLookup(something)
Next num

Enjoy

Ben ----------------------------------
Ben O'Hara
Home: bpo@RobotParade.co.uk
Work: bo104@westyorkshire.pnn.police.uk
Web: ----------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top