Back Colour Variable

  • Thread starter Thread starter Mark Cuthbertson
  • Start date Start date
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
 
Mark,

Try this approach:

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

HTH,
Nikos
 
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
 
Back
Top