loop through a set of controls

jillrein

Registered User.
Local time
Today, 11:34
Joined
Apr 19, 2008
Messages
28
I have 8 labels on a form that I want to be able to loop through changing properties such as visible and forecolor.

I tried naming them lbl(1), lbl(2) ... and refering to them as me.label(i).visible=true but that didn't work
then I tried naming them lbl1, lbl2 ... and referring to them as Me("lbl" & i).visible=true
and that failed as well.

Can anyone tell me how I can do this please
 
for i = 1 to 8
me("lbl" & i).visible = true
next

This code should work if you name your control name lbl1,lbl2 etc.
make sure it the control name that is lbl1 and not caption.
 
If you are still having issues, please post the actual VBA code you have tried.
 
Thank you - I just retyped it and it worked. Don't know why it didn't before.
 

Users who are viewing this thread

Back
Top Bottom