Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Background change in Crystal report

Posted on 2012-04-12
11
Medium Priority
?
407 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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

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 101

Assisted Solution

by:mlmcc
mlmcc earned 400 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

670 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