Referring to a control by using a variable

J

Jack G

I'm trying to change the FontBold property of a contol whose name is stored
as a variable, but I can't figure out the correct syntax. Here's one of my
attempts that doesn't work:

If CurrentLabel <> "lblCustomerList" Then Forms!Form1! & CurrentLabel &
..FontBold = False

I know I'm treating those as strings and they're not, but I can't figure how
else to combine the variable with the rest of the stuff. Thanks for any
help.

Jack
 
R

Rick Brandt

Jack said:
I'm trying to change the FontBold property of a contol whose name is
stored as a variable, but I can't figure out the correct syntax.
Here's one of my attempts that doesn't work:

If CurrentLabel <> "lblCustomerList" Then Forms!Form1! & CurrentLabel
& .FontBold = False

I know I'm treating those as strings and they're not, but I can't
figure how else to combine the variable with the rest of the stuff.
Thanks for any help.

Jack

Forms!Form1.Controls(VariableName)

which can be shortened to just...

Forms!Form1(VariableName)
 
Top