Solved

Crystal Rep Conditional Formatting?

Posted on 2000-05-04
4
556 Views
Last Modified: 2009-01-06
I'm hoping someone has done something like this before.

Can I do conditional formatting on a Crystal Report field.  eg.  If the val is negative, make it red, if it is positive, make it black.

If not, is there any way to fake it?
0
Comment
Question by:PaulHews
  • 2
4 Comments
 

Accepted Solution

by:
AZWolf7 earned 50 total points
ID: 2778873
Absolutely. Select the field you want to format this way, and right click. Next, select Format Field from the popup menu.

Let's call the field Amount.

Go to the font tab of the format menu.
Now, next to the font color, you will see a button with x+2 on it. Click it, and you will be able to add conditional code to the formatting.

You should be in the Format Formula Editor now. type an 'if ', then select the field (in this case, Amount) from the 1st column. You should see something like:

if {MyTable.Amount}

then continue to set you settings like:
if {MyTable.Amount} > 0 then
    black
else
    red


I am not sure the exact syntax for the color. You might have to change the code to say:
{MyTable.Amount}.Black
or
{MyTable.Amount}.Color = Black
0
 
LVL 32

Expert Comment

by:bhess1
ID: 2778878
I have a cheat that works.

Create two formulas that output your number using ToText to format it as a string.  The formulas should be like this:
----------------
If {MyDb.MyNumber}>=0 Then
ToText ({MyDb.MyNumber}, 2)
Else
""
-------------
and
----------------
If {MyDb.MyNumber}<0 Then
ToText ({MyDb.MyNumber}, 2)
Else
""
-------------

Now, place the formula boxes over each other, format one red, one black, and Voila!
0
 
LVL 32

Expert Comment

by:bhess1
ID: 2778883
Note that my version of Crystal does not support conditional formatting of fonts and font colors.  If yours does, AZWolf7's answer is much more elegant.  
0
 
LVL 38

Author Comment

by:PaulHews
ID: 2779085
Thank you both.  Fortunately, Crystal Version 6.0 supports this feature, so I'll give the points to AZWolf7
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now