Solved

Crystal Rep Conditional Formatting?

Posted on 2000-05-04
4
562 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

680 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