Full Version: Help with Conditional Formatting on a Calculated Field
UtterAccess Forums > Microsoft® Access > Access Forms
kthomascik
I need help with formatting one of the fields in my form. I have a field that I built the following expression into: =IIf(((1.25*[RealIncome])>=[EstimatedIncome]),"YES","NO") - so that if the value of Estimated Income is less than or equal to 125% of the Real Income then the field says YES and if it's greater than then the field says NO.
would like the field to be highlighted in yellow if it says NO so that it will be easier to focus on when reviewing the form. I have tried using the conditional formatting option on that specific field, but if I select Field Value = No, nothing happens and if I select expression is True both Yes and No turn yellow (If I select expression is False, nothing happens). I don't know how to base the conditional formatting of this field on the answer to the expression. Any help you could provide would be greatly appreciated! Thanks!
jzwp11
I would use VBA code to do what you want. In the on current event of the form you can add some code like this:
CODE

Private Sub Form_Current()
If Me.Text8 = "NO" Then
Me.Text8.BackColor = 65535
Else
Me.Text8.BackColor = -2147483643
End If
End Sub

You will have to substitute your control name in place of the Text8
trapperalexander
I agree with JZWP11, using code is a better way, plus Conditional Formatting limits you to 3 conditions!
But just some information that might solve your problem using the conditional formatting window...
1. When specifying a field value you will need to enclose the value in quotes ( ="No" or ="YES")
2. If the field value is boolean (true/false) you can specify =True or =False without the quotes
-Trapper
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.