Change group background colour (1 Viewer)

fat controller

Slightly round the bend..
Local time
Today, 20:52
Joined
Apr 14, 2011
Messages
758
I have a report which is grouped on a field which shows a Day Type, and I would like the background colour of the group to be changed depending on the value that is in the field.

For example, if it says Saturday, I would like the background of that section of the report to be light green; if Sunday, light red/pink; if Boxing Day then amber.

Now, my brain is screaming at me that this should be code in the On Format event for the group header, but what that code should be I don't know?

Also, would it be better (to allow flexibility going forward) if I had a table which had a list of the day types and then the associated colour, be that colour stored as RGB or HEX?
 

Ranman256

Well-known member
Local time
Today, 15:52
Joined
Apr 9, 2015
Messages
4,337
Make a table that holds the daysof week and their colors
[dow], [color]
1 , 10. (Sunday)
2 , 12. (Monday)

Join this table to your data query,and convert the date field to DOW.
Format([dateFld],"w")

Join the fields then in the form,use the OnCurrent event can change the color.
Me.backcolor= txtcolor
 

fat controller

Slightly round the bend..
Local time
Today, 20:52
Joined
Apr 14, 2011
Messages
758
Thanks :)

It is on my other PC which I have left in my office for now - I will have a crack at it tomorrow.
 

Users who are viewing this thread

Top Bottom