Back Colour Variable

M

Mark Cuthbertson

Hello,

I can set a variable to be the value of the back colour
of a square I have on a form using the line:

myVariable = Me!Light1.BackColour

where 'Light1' is the same of the square object.

I need to put this into a for loop so that I can change
the properties of all the 'Lights' on the form. I am
trying to use something like:

myVariable = "Me!Light" & x & ".BackColour"

but then Access just sees myVariable as a string rather
than the value of the objects backcolour. I'm sure I am
missing something very simple like the data type of
myVariable but I am not an experienced coder and am
having trouble!

Thank you for any help,

Mark
 
N

Nikos Yannacopoulos

Mark,

Try this approach:

ctlName = "Light" & x
myVariable = Me.Controls(ctlName).BackColor

HTH,
Nikos
 
B

Brian

Mark Cuthbertson said:
Hello,

I can set a variable to be the value of the back colour
of a square I have on a form using the line:

myVariable = Me!Light1.BackColour

where 'Light1' is the same of the square object.

I need to put this into a for loop so that I can change
the properties of all the 'Lights' on the form. I am
trying to use something like:

myVariable = "Me!Light" & x & ".BackColour"

but then Access just sees myVariable as a string rather
than the value of the objects backcolour. I'm sure I am
missing something very simple like the data type of
myVariable but I am not an experienced coder and am
having trouble!

Thank you for any help,

Mark

myVariable = Me("Light" & x).BackColor
 

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