Link to home
Start Free TrialLog in
Avatar of Jeremy Campbell
Jeremy CampbellFlag for United States of America

asked on

Trying to change color of text in Access form on textbox using conditional formatting.

I have a textbox called RESULT. It is always a number that is keyed in here.

There is also a PLUS field and a MINUS field that both return numbers.

I want to set conditional formatting to say that when the number in RESULT is greater than PLUS or LESS than MINUS then highlight the text red.

I started out by just trying to get the plus side working so I created this;
User generated image
It seems to have a problem with numbers that contain decimals.

So when I have a RESULT that is .940 and the PLUS number is .950 it will not highlight the RESULT Red until it is 1.000 or greater.. I would expect it to highlight when it is greater than .950.. So .9501 should highlight red.

Thanks in advance for the help!
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

try, using Expression is

expression is [Result]>[Plus] Or [Result]<[Minus]
<RESULT that is .940 and the PLUS number is .950 it will not highlight the RESULT Red>

.940 is less than .950
Avatar of Jeremy Campbell

ASKER

I tried that initially and its giving me some really wierd results..

Here is a screenshot of what's being highlighted..
User generated image
<RESULT that is .940 and the PLUS number is .950 it will not highlight the RESULT Red>

Sorry that may have not made any since..

Basically when the result is not falling within the range then I would like for it to highlight red..
Oh and in the picture the plus and minus labels should be switched..
Maybe my PLUS and MINUS fields are note being treated as numbers but rather text? They are created using some VBA that I'm still tweaking on another question.

Can I do something like set up a textbox that will convert them to a number that goes to 4 decimal places?

NewPLUS= ToNumber([PLUS], 0000.0000) ? Something like this perhaps?
<RESULT is greater than PLUS or LESS than MINUS then highlight the text red.>

setting
                   expression is [Result]>[Plus] Or [Result]<[Minus]

<Basically when the result is not falling within the range then I would like for it to highlight red..>

the setting will be

                 expression is [Result]>[Plus] And [Result]<[Minus]
Changing it to this doesn't seem to make it highlight anything.. Here is some numbers I through in to see;
User generated image
Here is the current formatting;
User generated image
sorry

the setting will be

                 expression is [Minus] > [Result] Or [Plus] < [Result]
the same as

                 expression is [Result]>[Plus] Or [Result]<[Minus]
What is the data type of these fields?  If they are text fields, you could convert their values to Double values for comparison.
I'm convinced these fields need to be converted to numbers.. Not sure how to do that though.. It needs to handle up to 0000.0000 if possible..
Oh and capricorn in response to your latest expression;

expression is [Minus] > [Result] Or [Plus] < [Result]

Here is some results that it is giving me..;

User generated image
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
or this

expression is CDbl([Minus]) > CDbl([Result]) Or CDbl([Plus]) < CDbl([Result])
That did the trick! Now its working:)