Conditional Colors

  • Thread starter Thread starter L Manios
  • Start date Start date
L

L Manios

Ok, I've been playing a bit with the conditional color feature in Access
2002 reports and hit upon a few snags.

* It only lets you do up to 3 colors. What can I do if I want to have more
than 3 colors as possible choices? I've layered a bunch of text fields of
the same size atop of each other so that they color only when they get
triggered, but there has to be something more elegant than this. In other
words, can one code the boxes to color rather than using Microsofts user
interface?

* Next, the colors are limited to the pallate that Uncle Bill gives you.
Can you store the color in a field and have the report color the box based
on the color code stored in the table?

Lou
 
Consider consulting with a usability designer. I've seen some suggestions
that adding many colors, fonts, etc. does not improve readability.

If you'd still like to "light up" your reports, take a look at the OnFormat
event -- you may be able to put the code "behind form/report" to test and
color, using the ?16 million color palette.

Good luck

Jeff Boyce
<Access MVP>
 
Forget about CF. Just use the Format event of the section containing the
controls whose properties you want to modify.

--
HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
Here are 4 conditional forecolor choices as well as a default black.

In the Report's Detail Section's Format event:
If [SomeControl] = 10 Then
[SomeControl].ForeColor = vbRed
ElseIf [SomeControl] = 25 Then
[SomeControl].ForeColor = 12632256 ' a gray
ElseIf [SomeControl] = 34 Then
[SomeControl].ForeColor = 9868950 ' a darker gray
ElseIf [SomeControl] = 48 Then
[SomeControl] = 8388608 ' a shade of blue
' You can continue with as many ElseIf's as you need,
' and change the color values as wanted.
Else
[SomeControl].ForeColor = vbBlack ' default color
End If

Look up the vb color constants in VBA help for the basic colors available
using a constant, then use the color chart to select millions more colors.
Click on any control's color property (forecolor, backcolor, etc.).
Then click on the button with the 3 dots that will appear on that line.
When the color chart opens, select Define Custom Colors.
Make your own color. Copy the color to the control. Write down that color
number and use it in your code. Remember to then place the original color
value back in that control.

As far as storing the color in a table, I haven't done it, but I don't see
why not, as long as it's the color number value you store (0 for Black,
12632256 for gray, etc.), and not a text 'Gray'.
You'll then need a DLookUp with criteria to find the appropriate color for
the control value.
 
Back
Top