Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Color a field red

Status
Not open for further replies.

psperry2

Programmer
Nov 7, 2007
141
US
I tried to put this formula in the 'Format Formula Editor: Font_Color' and I am not sure why it doesn't work. Basically I have got @RED set either to 1 or 0. So testing this I need a formula that will print the field in red and maybe italics also.


IF @RED THEN crRed
ELSE crnocolor
 
IF @RED = 1 THEN crRed
ELSE crnocolor

-LB
 
That didn't work. I check the formula and get this message:
"A number, currency amount, boolean, date, time, date-time, or string is expected here"

I am using crystal 8.5
 
You need to show us the content of {@red}.

-LB
 
It might be that your 1 or 0 is a text field?
Try:

IF @RED = "1" THEN crRed
ELSE crnocolor
 
remove the quotes from @RED = "1" and try.

Use this:
IF @RED = 1 THEN crRed
ELSE crnocolor

Thanks,
Madhu
 
This is the code that sets the @RED:

IF {BATCH.PAYMENTTYPE} IN ['VISA;VI','MC / Eurocard;MC','American Express;AE','Diners Club;DC'] AND
(ISNULL({BATCH.AUTHNUM}) OR {BATCH.AUTHNUM} = ' ' OR
{BATCH.AUTHNUM} IN ['CALL AUTH CENTER','DECLINED','Duplicate Trans','EXPIRED CARD','File Error','ConnErr',
'No Response','REFERRAL','User Not Found','CALL AUTH CENTER'] OR
{BATCH.AUTHNUM} LIKE '*Post Auth*' OR
{BATCH.AUTHNUM} LIKE '*CALL AUTH*' OR
{BATCH.AUTHNUM} LIKE '*PLEASE RETRY*')
THEN 1
ELSE 0
 
Can you verify that {@Red} does not generate an error and is giving the correct result if placed in the detail section?

-LB
 
Yes I can. Right now there are no problems which would cause the @RED to be set to 1. It is always zero. There are no errors and the @RED field displays on the report.
 
Therefore the font color formula is working correctly also. If it isn't 1, it doesn't turn red.

-LB
 
This is the formula that I get the error message:

IF @RED >0 THEN crRed ELSE crnocolor

error message:

The message is: A number, currency amount, boolean, date, time, date-time or string is expected here.
 

Right click the field in the report.
<Format Field>
<Font>
Click the X-2 across from Color and type in
IF @RED = 1 THEN crRed
ELSE crnocolor

This worked for me.

SP
 
Where are you placing this formula? Where is the cursor when you get this message?

-LB
 
Spcc07 I did as you suggested and still get the error when I click the check formula button.


lbass I put this formula in on the 'Format Formula Editor: Font_Color' Screen that you get when you do as Spcc07 specified.
 
After much experimentation this works for me:

IIF({@RED}=1,crRed,crnocolor)
 
It makes no sense that the iif would work if the formula itself didn't.

To do italics, try the same thing in the font style area, substituting crItalics, and crRegular.

-LB
 
OHHHH!!! Yes, that would be it. You should just select the formula from the field list, and the curly braces will automatically be there. I didn't even notice that they weren't there.

-LB
 
WOW!!! LOL I have been following this thread trying to figure out what the heck?!?!?! I didnt even notice the {} either.

_____________________________________
Crystal Reports XI Developer Version
Intersystems Cache 5.X ODBC connection

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top