Color Selection by Group

  • Thread starter Thread starter Tina
  • Start date Start date
T

Tina

How do I write code so that the color of a group is
selected by the items inside that group. Ex: Group name is
Process. This group has 4 items and each item is either
Red, Yellow, or Green. I need the Group name to change
from Green if there are any Yellow items. And from Yellow
to Red if there are any Red items.
 
Tina said:
How do I write code so that the color of a group is
selected by the items inside that group. Ex: Group name is
Process. This group has 4 items and each item is either
Red, Yellow, or Green. I need the Group name to change
from Green if there are any Yellow items. And from Yellow
to Red if there are any Red items.


We will have to know how the color is specified in the data
table. Is it a number (e.g. 1 = green, 2 = yellow,...)? or
is it text (e.g. Green = green,...)?

Once we know that, create a text box named txtRedCnt in the
group header section with an expression something like:
=Count(IIf(colorfield = "Red", 1, Null))
and another similar one for Yellow.

Then you can use code in the group header's Format event
procedure:

If txtRedCnt > 0 Then
Me.txtgroupname.ForeColor = vbRed
ElseIf txtYellowCnt > 0 Then
Me.txtgroupname.ForeColor = vbYellow
Else
Me.txtgroupname.ForeColor = vbBlack
End If
 
Back
Top