Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fading Background Color 11

Status
Not open for further replies.

hhiebert

MIS
Feb 28, 2003
25
0
0
CA
Is it possible to add fading colour to your report. For instance, can the background colour of the Details section become more and more light with each record?

hh-
 
Sure.

Insert a formula like the one below into your Details section.
Code:
WhilePrintingRecords;
NumberVar Counter;

If Counter + 3 >= 255
Then Counter := 0
Else Counter := Counter + 3;
Then, format your Details section, and conditionally colour it with the following:
Code:
Color(255,255,NumberVar Counter)

If you want the colour to reset for each group, you can reset the color by resetting the variable in the group header with Counter := 0.

This example will loop back to a darker colour once the counter hits 255, but you can use 3 variables in much the same way as I have shown you in this example, with the end result looking like Color(Variable1,Variable2,Variable3)

If you do need an option like that, but can't create it yourself, then come back and I or someone else will show you what to do.

All the best,

Naith
 
I'm getting a background of all the same color. I even tried adding WhilePrintingRecords to the Condition formula.

Any ideas what I'm missing?
 
Ignore my last post Naith. It was working...I just didn't have enough records in my report to notice the change with an increment of 3.

Also, I didn't need to add the WhilePrintingRecords statement.

Thanks so much for your insight.

hh...
 
Thanks for the inspiration, Naith. That is a fun idea. I may describe it in my newslettter, and I will give you credit for starting the ball rolling. I discovered that you can combine these into one formula and put it all into the format property - if you are accumulating at the detail level.

For those of you who would like a visual of the RGB pallett within Crystal, you can use any color selector to select "Custom" at the bottom. Then use the "Define Custom Colors" button to open the pallet. Click anywhere in the pallet to get your color, and then slide the right arrow to set the luminosity. The RGB values will appear in the bottom right.

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Expert's Guide to Formulas / Guide to Crystal in VB
- tek@kenhamady.com
 
Dear Naith,

So cool!* I am teaching a Crystal Class this week (in Toronto now) and I am going to show this as a fun exercise! I will, of course, give you credit!

best regards,

ro Rosemary Lieberman
rosemary@microflo.com, Microflo provides expert consulting on MagicTSD and Crystal Reports.
 
This is fantastic advice Naith[2thumbsup]! Fun and inventive! Would you please post a small FAQ so that others can refer to this in the future?

 
Naith*:

Again, great tip. I tried it out and noticed that every page looked different, depending on the size of your detail section. I started playing around with it so that I could get the fade consistent across every page and this is what I came up with.

I altered the first formula this way:

WhilePrintingRecords;
NumberVar Counter;
NumberVar IncrementValue := 6;

If Counter + IncrementValue >= 255
Then Counter := 255
Else Counter := Counter + IncrementValue;

I also created a second formula with the contents below and added it to the page footer. If you put it in the page header, the first record on pages 2+ don't evaluate properly and end up white.

WhilePrintingRecords;
NumberVar Counter := 0;

This will cause Counter to reset for every page, giving you the same look for every page. Also, if you set your margins to 0, and copy what Naith posted above for the Detail Section Color into your Page Header Color formula, the whole page color will fade without any breaks.

Again, thanks for the inspiration Naith. ~Brian
 
Dear Brian:

Very Nice!* and a star for you for improving it just in time for my class tomorrow <grin>.

ro Rosemary Lieberman
rosemary@microflo.com, Microflo provides expert consulting on MagicTSD and Crystal Reports.
 
Thanks for the stars guys.

The original formula was a bit quick and dirty, so it benefits from Brian's extra work.

Have a great week!

Naith
 
Brian,

I've plaguerised from your formula to illustrate the 3 variable example I mentioned in my initial post.

//ReportHeader:
WhilePrintingRecords;
NumberVar CounterX := 0;
NumberVar CounterY := 255;
NumberVar CounterZ := 255;

//Details:
WhilePrintingRecords;
NumberVar CounterX;
NumberVar CounterY;
NumberVar CounterZ;
NumberVar IncrementValue := 5;

If CounterX + IncrementValue >= 255
Then
If CounterY - IncrementValue < 0
Then
If CounterZ - IncrementValue < 0
Then CounterZ := 0
Else CounterZ := CounterZ - IncrementValue
Else CounterY := CounterY - IncrementValue
Else CounterX := CounterX + IncrementValue;

//Conditional Colour in Details:
Color(NumberVar CounterX,NumberVar CounterY,NumberVar CounterZ)

I am not responsible for your users reactions.

Naith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top