Solved

Crystal Rep Conditional Formatting?

Posted on 2000-05-04
4
563 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

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.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…

751 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