Setting the RGB color of multiple fields at the same time

Tuesday 17 August 2010 @ 11:14 pm

One of my customers had a dozen or so formula fields used as headings throughout a long report.  He wanted to be able to adjust the color of the font assigned to all of these objects in one place.  So we created a formula that stored three numeric values like this and put it into the report header (suppressed):

WhilePrintingRecords;
NumberVar RGB1 := 0;
NumberVar RGB2 := 64;
NumberVar RGB3 := 128;

Then we used the following as the condition formula for the font color of all of those objects:

WhilePrintingRecords;
NumberVar RGB1 ;
NumberVar RGB2 ;
NumberVar RGB3 ;
RGB (RGB1,RGB2,RGB3)

By changing the values in the first formula he could control the color of all the fields that were formatted with the second formula. But as we did this I noticed something I had never noticed before.  You can control the font color of any field or formula using the font color condition button.  But if you try to do the same thing with a text object, like a column heading you will notice that the properties on the “Font” tab do not have any conditional formatting buttons.  If you want to have text headings that change color in this way you will need to replace the static field headings with formula fields.  That way you can have the same static text, but ALSO have the ability to set font properties (like colors) based on conditions.

If you want to learn more about RGB colors you can read an earlier blog post about them

(For examples of my most popular formulas, please visit the FORMULAS page on my website.)







Leave a Reply

Jeff-Net
Recrystallize Pro

Crystal Reports Server