Solved

Background change in Crystal report

Posted on 2012-04-12
11
405 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel Automation VBA 19 116
VBA to find and replace multiline text from VBA modules 8 108
Timezone help 5 45
Visual Basic 6: Code needed for TripleDES Encryption/Decryption 14 95
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…

710 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