Solved

Background change in Crystal report

Posted on 2012-04-12
11
400 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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
 
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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
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…

803 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