Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Crystal Rep Conditional Formatting?

Posted on 2000-05-04
4
Medium Priority
?
566 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 200 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:Brendt Hess
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:Brendt Hess
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Suggested Courses

721 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