Another Conditional Formatting Question

T

tkosel

I hope I have searched enough to NOT have missed the answer that is already
there, but I don't think so. I have several conditions that need to be
formatted for.
When a field value is the # indicated, I want the colors to be as indicated.

0 = Green text on Light Green
1 = Black text on Light Yellow
2 = Black text on Gold
3 = Black text on Orange
4 = White text on Red

I know how to set conditional formating, but am one condition short? Any
ideas, or what am I missing?
 
M

Maarkr

I think you can only identify 3 values for conditional format... you may be
able to do it with code depending on if your field is in a single form,
continuous form, or report. Give us your details on if it's a combo box, etc
also.
 
T

tkosel

The field(s) are on a continuous form that is a subform on another form. I
actually want to turn the whole line on the form the same color, but have one
field named "Status" that I can use in the expression used for the
conditional format of all the fields. All of the fields are bound text
boxes. Again, I think I may be out of luck as I think you are correct, only
three conditions are available. Looking for a trick! Thanks.
 
J

Jim Ory

I am using WinXP and Access2K2, but should work with your version.

On the form's current event try this:

If me.yourstatusbox = 0 then
me.yourfield.backcolor = RGB(255, 255, 0) 'Yellow
me.yourfield.forecolor = RGB(0, 0, 0) 'Black
Else: me.yourfield.backcolor = RGB(0, 255, 0) 'Green
me.yourfield.forecolor = RGB(255, 255, 255) 'White
End IF

The RGB( 255, 255, 255) designation is for the colors and can be anything
from 0-255 in each case. You will have to play with the numbers to get the
required color combination.

In the Help section of visual basic, search for RGB function. You should
find what basic color numbers are and you can increase or decrease the
numbers for them to display different colors.

Also, look at Backcolor Property for an example of changing text box colors,
etc.

Another thing I found is that you must change each text box back style
property from 'transparent' to 'normal' for the colors to show up.

Here are the basic colors. The numbers are formatted like: RGB(X, X, X)

Black 0 0 0
Blue 0 0 255
Green 0 255 0
Cyan 0 255 255
Red 255 0 0
Magenta 255 0 255
Yellow 255 255 0
White 255 255 255
 

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