run a code based on the field conditional formatting back color

S

Silvio

I would like to run a code (if...then...else) based on conditional
formatting. MS Access conditional formatting will turn RED my field back
color if the value in it is >10 (This works fine). Then I have a button that
on-click will check each field in my form to see if any filed is red because
of the conditional formatting formula, and if that is the case, run another
line of code. The problem I am having is that my code does not appears to
detect the color even though I can see it (Red field)

My code:
if [frmCalibration2].Form![frmOxygen1].Form![Difference].BackColor = 255 then
do this..
else
do that
end if

What I am doing wrong? Color-code for the red in conditional formatting is
255, correct? is .BackColor what I need to check?

Thank you,
Silvio
 
M

Mike Painter

Silvio said:
I would like to run a code (if...then...else) based on conditional
formatting. MS Access conditional formatting will turn RED my field
back color if the value in it is >10 (This works fine). Then I have a
button that on-click will check each field in my form to see if any
filed is red because of the conditional formatting formula, and if
that is the case, run another line of code. The problem I am having
is that my code does not appears to detect the color even though I
can see it (Red field)

My code:
if [frmCalibration2].Form![frmOxygen1].Form![Difference].BackColor =
255 then do this..
else
do that
end if

What I am doing wrong? Color-code for the red in conditional
formatting is 255, correct? is .BackColor what I need to check?
Base your check on the condition that causes the change.
I doubt that Access sets the color property.
 
S

Silvio

That's exactly what I want to avoid doing.

Mike Painter said:
Silvio said:
I would like to run a code (if...then...else) based on conditional
formatting. MS Access conditional formatting will turn RED my field
back color if the value in it is >10 (This works fine). Then I have a
button that on-click will check each field in my form to see if any
filed is red because of the conditional formatting formula, and if
that is the case, run another line of code. The problem I am having
is that my code does not appears to detect the color even though I
can see it (Red field)

My code:
if [frmCalibration2].Form![frmOxygen1].Form![Difference].BackColor =
255 then do this..
else
do that
end if

What I am doing wrong? Color-code for the red in conditional
formatting is 255, correct? is .BackColor what I need to check?
Base your check on the condition that causes the change.
I doubt that Access sets the color property.
 
M

Mike Painter

Then run code that pops a message box with the back color and see what it
says.
It may be some shade of red, but I'm guessing Access sets it without
touching the default backcolor.
Are you checking "each field in my form" or checking a particular column on
a subform?
I'd check the value and unless the button is optional or you do different
things based on the number of red field when done, get rid of the button.
That's exactly what I want to avoid doing.

Mike Painter said:
Silvio said:
I would like to run a code (if...then...else) based on conditional
formatting. MS Access conditional formatting will turn RED my field
back color if the value in it is >10 (This works fine). Then I have
a button that on-click will check each field in my form to see if
any filed is red because of the conditional formatting formula, and
if that is the case, run another line of code. The problem I am
having is that my code does not appears to detect the color even
though I can see it (Red field)

My code:
if [frmCalibration2].Form![frmOxygen1].Form![Difference].BackColor =
255 then do this..
else
do that
end if

What I am doing wrong? Color-code for the red in conditional
formatting is 255, correct? is .BackColor what I need to check?
Base your check on the condition that causes the change.
I doubt that Access sets the color property.
 

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