cancel
Showing results for 
Search instead for 
Did you mean: 

changing fonts conditionally

Former Member
0 Kudos

Post Author: MikeA-ICE

CA Forum: General

I want to set up an if then else formula to change the color of the font on a field and I can't seem to find out how to do it in Crystal 11. Crystal 6 had a formula editor button to the right of it and I used it extensively but in both Crystal 9 and 11 that button has been removed. How does one go about conditionally changing the font. The weird thing is that the Crystal Reports XI Users Guide has a section on conditionally changing fonts and it states you can change all the attributes of a font by using the formula editor buttons but there's not a single one on the formatting window I'm looking at.

Thanks,

Mike A

EDIT:

A little more info. I'm not finding the formula button to change font color in the formatting window for a TEXT BOX. Formula fields and data fields seem to have it.

Accepted Solutions (0)

Answers (8)

Answers (8)

Former Member
0 Kudos

Post Author: MikeA-ICE

CA Forum: General

Thanks for all the replys. Yep, it's true. Text fields cannot be conditionally formatted. Just another of those mysteries of life I call "Crystal Quirks". This must be some sort of oversight on the part of Business Objects because I checked it in Crystal 6 which I still have on another machine and that option was available. I tried the solution that nchan suggested and it worked have almost worked but I ran into some situation where it didn't. (it's been a few days now and I can't remember the detail of why it wouldn't.)

I did get around this though. The text boxes (4 of them) that I wanted to change if a condition was met were in a Group Footer. I also had a couple of formula fields in there too. I simply added another Group Footer section below, duplicated the items in the new section and set A to suppress and B to show if the condition was met. If it wasn't, then A showed and B was suppressed. It not exceedingly elegant but it works.

Thanks again,

Mike

Former Member
0 Kudos

Post Author: nchan

CA Forum: General

The formula could be placed in the details or group sections(group header and group footer). would be any field that you are pulling from your database. Say for example you have field {Appt.Status} and you want the text to be bolded and green if they have arrived. The formula would be something like:

if {Appt.Status}="Arrived" then (crbold crgreen totext("Patient has arrived")) else (totext("Not Arrived"))

The output of the text then should be green and bolded if the patient has arrived. Otherwise, the formula would output regular Not Arrived.

As for your last statement rcoleman, formatting fields is normally done by right clicking and selecting, "Format Field" but it is not possible to format an inserted text box, conditionally. Sure you can change the text color and size, but doing that only changes the text for every instance it shows in the report. Instead, if you create a formula, you can conditionally format text using the if then else statements and crbold, critalic, crgreen, etc... making it different for each row based on data from the database. Basically a few extra steps to conditionally format a text box. I use this for when I want the entire row to match because it meets a certain criteria to offset it from the rest. Hope this helps.

Former Member
0 Kudos

Post Author: rcoleman

CA Forum: General

I didn't ask the original question but the last response has me wondering. First of all where would the formula be placed? Second question- in regards to 'if = "something".... what field does represent? It's my understanding and experience that you can format the fields in the text box but not the text itself. Can this be clarified for me?

Former Member
0 Kudos

Post Author: nchan

CA Forum: General

There is no way to change the text conditionally. What you can do though is create a formula to do this. Here is an example.

if ="something" then (crbold crgreen totext("Hello")) else (critalic totext("Goodbye"))

There are commands that can format text in a formula that start with cr and end with bold, italic, or any color name. That should format the text to your desired results.

Former Member
0 Kudos

Post Author: Bandit07

CA Forum: General

I use Vr 10 Dev. and it looks like only border and background colors can have conditional formating on text fields.

B

Former Member
0 Kudos

Post Author: rcoleman

CA Forum: General

No, that doesn't seem to format the text, only fields that have been added. Didn't mean to get your hopes up.

Former Member
0 Kudos

Post Author: rcoleman

CA Forum: General

You should be able to double click the text box, highlight and right click the text you wish to format. You'll then see the 'text formatting' option.

Former Member
0 Kudos

Post Author: simon82

CA Forum: General

could you not write this as a fomula field and place this field on the report?