Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditional Formatting

Status
Not open for further replies.

LucyColey

Programmer
Apr 30, 2001
34
0
0
US
I need to conditionally format something based on another field. If FIELD1 is LIKE a specified value, I want to highlight FIELD2. I run into my problem when I want to highlight FIELD2 when FIELD1 is LIKE one of two specified values.

I've tried two ways at looking at this. The first is to conditionally format the background of FIELD2.

If {InsertRejects9.ForcedError} Like '*|33|*'
Then Silver
Else If {InsertRejects9.ForcedError} Like '*|32|*'
Then Silver
Else White

When I do this, the ELSE statement works, but the IF statements do not.

The other method that I've used is to place a text box with a silver background behind FIELD2, then conditionally suppress it.

If Not({InsertRejects9.ForcedError} Like '*|32|*')
Then True
Else False;
If Not({InsertRejects9.ForcedError} Like '*|33|*')
Then True
Else False;

When I do this, it will only work on the second statement. I've tried using an OR statement, but run into the same problem.

If ((Not({InsertRejects9.ForcedError} Like '*|32|*'))
OR (Not({InsertRejects9.ForcedError} Like '*|33|*')))
Then True
Else False

Does anybody have any ideas on how to make this work?

Thanks!
 
The first one should work, but can be simplified by using:

If {InsertRejects9.ForcedError}
Like [ '*|33|*' , '*|32|*' ]
Then Silver
Else White

What does it do? Do the vertical bars appear in the text?
As a test, try a formula field on the details with the following formula to confirm that your formula is accurate:

{InsertRejects9.ForcedError} Like [ '*|33|*' , '*|32|*' ]


see if this gives you True and False on the appropriate records.
Ken Hamady
On-site custom Crystal Reports Training and Consulting.
Quick Reference Guide to using Crystal in VB.
 
Something funky is going on here. First, to answer your question, the vertical bars are in the string, they separate codes populating a single field (it wasn't the best way the programmers could have set up this table).

Second, I tried your recommendation, but instead of using white, I changed it to black so I could see it. I also created the formula that you sent me. What happens is that the TRUEs stay white and the FALSEs turn black. I just can't get the Trues to change colors when one or more conditions would cause this to happen! Any more ideas that might help?

Thanks!
 
So the trues and falses occur in the right places when you put the field on the detail band, but the colors don't follow correctly? What was the last actual condition formula? Ken Hamady
On-site custom Crystal Reports Training and Consulting.
Quick Reference Guide to using Crystal in VB.
 
Yes, the Trues and Falses are correct, but the highlighting on the Trues is not. The formula I used is:

If {InsertRejects9.ForcedError}
Like [ '*|33|*' , '*|32|*' ]
Then Silver
Else Black

To give you an example of what I'm getting, there is a record where the {InsertRejects9.ForcedError} = '|29|33|'. The test formula value = TRUE, but the conditional highlighting stays white. On a different record, the {InsertRejects9.ForcedError} = '31'. The test formula value = FALSE and the conditional highlighting changes the field to BLACK. I'm at a loss. This should be working!

Thanks for your help.
 
Could you try to use 'crWhite'
and 'crBlack' instead of 'White'
and 'Black' ?

Cheers,
- Ido ixm7@psu.edu
 
Where exactly are you putting your formatting condition?

What if you try the following formula that should highlight every record in Silver:

If {InsertRejects9.ForcedError} <> 'XX'
Then Silver
Else Black Ken Hamady
On-site custom Crystal Reports Training and Consulting.
Quick Reference Guide to using Crystal in VB.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top