Solved

Background change in Crystal report

Posted on 2012-04-12
11
396 Views
Last Modified: 2012-04-12
Hi

I have a report with 1 column. For example :

Heading1
wewewew
wewewew
wesd
sd
Heading2
sdsdf
sfdfv
Heading3
svdfvlkdfv
dbgb
gb
gb
fb
fbgtb
rbr
b
Heading4
ojkjfdg
elgjlg
kljfg

Now I want to color these in different colors like in different section:

In blue Color :
Heading1
wewewew
wewewew
wesd
sd

In Green Color :
Heading2
sdsdf
sfdfv

In Red Color :
Heading3
svdfvlkdfv
dbgb
gb
gb
fb
fbgtb
rbr
b

In black color
Heading4
ojkjfdg
elgjlg
kljfg


Thanks ..
0
Comment
Question by:sunilsagar
  • 6
  • 3
  • 2
11 Comments
 

Author Comment

by:sunilsagar
ID: 37837766
Please help the string I could write.
0
 
LVL 77

Expert Comment

by:peter57r
ID: 37838095
Are there always 4 headings ?

If not, what should happen if there are more than 4?
and what should happen if there are fewer than 4?

How is a 'heading' value different to any other value?  Are you using a grouping field to put similar values into the same group?
0
 

Author Comment

by:sunilsagar
ID: 37838382
There will be maximum 5 headings and there are chances that it would be less than 5.
All the values in the column are just list of values and they are all character data type.

No we are not grouping it, the data is already ordered and grouped (which is done at the database level)...what we see in Crystal Report is as values in single column.

I hope this makes things clearer.
0
 
LVL 77

Expert Comment

by:peter57r
ID: 37838418
SO how do you know which record is a 'heading'?

What if there are say only 2 'groups' - how do you decide which colours to use - is the first group ALWAYS Blue, the second Always Green and so on, or does the colour  depend on the 'heading' value?
0
 

Author Comment

by:sunilsagar
ID: 37838444
They are specific and distinct names like heading1 and heading2 , which never repeats.

And color will depend on the heading value. So Heading1 will be always blue and all the records will be blue until it reaches heading2 , and once heading2 is found, heading2 and all the  records below it will be green until it reaches to heading3 and so on ...  

Thanks
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 77

Accepted Solution

by:
peter57r earned 400 total points
ID: 37838634
You can do this using a couple of formula fields and a background formatting expression in the detail section.

I've just built this for 3 headings  - you can extend it as far as you wish...

Use a formula field like this - it must be added to the detail section..

whileprintingrecords;
stringvar lastone;
if {table.fieldName} in ["Heading1", "Heading2","Heading3"] then lastone :={table.fieldName};
""
In the report header add an initialisation formula field..

stringvar lastone:="xx";
""

Go to the [X+2] conditional format button for the background of the detail section and do..

stringvar lastone;
if lastone = "Heading1" then
crGreen
else if lastone = "Heading2" then
crRed
else if lastone ="Heading3"
then crYellow
else
crblue
0
 

Author Comment

by:sunilsagar
ID: 37838654
thank you so much peter57r, I will apply the same and will let you know.
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 37840782
If that doesn't work please explain how the data structure.
Is each line above a single record or a field in a record?

mlmcc
0
 

Author Comment

by:sunilsagar
ID: 37840790
This didn't worked, actually .. it changed the background of Headings only not the records below the heading :(
0
 
LVL 100

Assisted Solution

by:mlmcc
mlmcc earned 100 total points
ID: 37840912
Add WhilePrintingrecords; as the first line in the formatting formula

mlmcc
0
 

Author Closing Comment

by:sunilsagar
ID: 37841062
it worked. Thanks so much guys.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

706 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now