Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: How to Set Background color for cell empty string Post Reply Post New Topic
Author Message
huynhng
Newbie
Newbie


Joined: 18 Nov 2008
Location: Singapore
Online Status: Offline
Posts: 5
Quote huynhng Replybullet Topic: How to Set Background color for cell empty string
     Posted: 18 Nov 2008 at 2:27am
Hi all,
 
    I have 2 colums in report (CR 10): ColumnA and ColumnB.
    I set background color formula for ColumnB:
         if(strcmp({ColumnA}, {ColumnB}) = 0) then
               crred
         else
               nocolor
    (it mean: if 2 columns are different value --> column B is set to red "Background" color
    case 1: columnA with value 'aaa' and columnB with value 'bbb' --> columnB is set to red in background
 
    case 2: columnA with value 'aaa' and columnB with value ' ' (one space, i get this value from DB) --> columnB is not set red in background althought 2 column is different. (I think Crystal Report can not apply formula for blank, null, event one space character)
 
     Any body have solution please tell me asap! Dose CR support formular for case 2
 
Thanks and regards,
Huynh


Edited by huynhng - 18 Nov 2008 at 5:28am
No comment
IP IP Logged
rahulwalawalkar
Senior Member
Senior Member
Avatar

Joined: 08 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 731
Quote rahulwalawalkar Replybullet Posted: 18 Nov 2008 at 5:43am

Hi

Check for the conditions as below

if isnull({columnB}) or (strcmp({columnA}, {columnB}) <> 0) then
      formula =   crred
else
      formula = crwhite

cheers
Rahul
 


Edited by rahulwalawalkar - 18 Nov 2008 at 5:45am
IP IP Logged
huynhng
Newbie
Newbie


Joined: 18 Nov 2008
Location: Singapore
Online Status: Offline
Posts: 5
Quote huynhng Replybullet Posted: 18 Nov 2008 at 5:56am
Hi,
   The formula will not effect with value of the column is blank or null
   You can try by add formula on only one column with crred on background (this is a simple formula)
   ex: on ColumnA --> background color: add formular: crred
   This formula only effect when value of cell not blank or null. So if I use your formula:
    if isnull({columnB}) or (strcmp({columnA}, {columnB}) <> 0) then
      formula =   crred
else
      formula = crwhite
 
   It will do nothing
No comment
IP IP Logged
rahulwalawalkar
Senior Member
Senior Member
Avatar

Joined: 08 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 731
Quote rahulwalawalkar Replybullet Posted: 18 Nov 2008 at 5:58am

did u use it...............

post me the sample data for column a and column b

cheers

Rahul



Edited by rahulwalawalkar - 18 Nov 2008 at 6:01am
IP IP Logged
huynhng
Newbie
Newbie


Joined: 18 Nov 2008
Location: Singapore
Online Status: Offline
Posts: 5
Quote huynhng Replybullet Posted: 18 Nov 2008 at 6:10am

Database

TestTable

ColumA  ColumnB

Test 1     Test B2
Test 2     
Test 3     
Test 4     Test B2
 
Add formular in Blackground:
if({TestTable.ColumnA} <> {TestTable.ColumnB}) then
      crred
else
      nocolor
 
Report:
 
ColumnA     ColumnB
Test 1         Test B2 --> red background color
Test 2                      --> nothing
Test 3                      --> nothing
Test 4         Test B2 --> red background color
 
You can change the formular by check isnull, but it still not effect
 
Thanks
No comment
IP IP Logged
rahulwalawalkar
Senior Member
Senior Member
Avatar

Joined: 08 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 731
Quote rahulwalawalkar Replybullet Posted: 18 Nov 2008 at 6:11am
Hi
Do this
 
Insert a textobject  and write the formula in your textobject background
 
and then place the field in your text object this will do the trick..............
 
Cheers
Rahul
IP IP Logged
huynhng
Newbie
Newbie


Joined: 18 Nov 2008
Location: Singapore
Online Status: Offline
Posts: 5
Quote huynhng Replybullet Posted: 18 Nov 2008 at 6:30am
HI
  It effected. So I don't know why formular did not effect in field!
 
Thanks so much
Huynh
No comment
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum