Skip to Content
0
Former Member
Dec 02, 2006 at 06:29 AM

Conditional Formatting (a simple example)

71 Views

Plz forgive the simplicity of this example [I'm a CR4Eclipse newbie].

I had trouble coming up with the right date style when conditionally formatting a column based on a value in CR4Eclipse. I found a complex example, but it didn't help with the required date format, so I thought I'd post this for other newbies.

Paste the code snippet below into your Formulas tab [change the table/col names], or right-click a column in your report layout, click "Conditional Formulas...", then select Font Color from the drop-down.

HINT: If don't know what format/style to use in the conditional formula for numbers, dates, etc., try hard-coding a filter on one of your columns to figure how to get the right date style for your formula.

MYTABLEMYCOLUMN_DATE : Font Color

//

// Return the font color to use for this field.

// Return values: Color (red, green, blue), crBlack, crMaroon, crGreen, crOlive,

// crNavy,crPurple,crTeal,crSilver,crRed, crLime,crYellow,crBlue,crFuchsia,

// crAqua,crWhite,crNoColor

//

// Abbie Hoffman always said you can't trust anybody over 30, so

// font=green if date is greater than 12/01/1976 else font=red

if {MYTABLE.MYCOLUMN} >= #1976-1-1 0:0:0# then

crGreen

else

crRed