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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Alternating color per every row 2

Status
Not open for further replies.

dky1e

Programmer
May 4, 2002
293
US
Hi,

Is it possible to alternate the back ground color for each row in a report, or even better-every 2 rows?

This is what I want to accomplish (example):
[tt]
[bg color] Product Cost
[gray] Ball $5
[gray] Bike $10
[white] Bat $2
[white] Shoe $4
[gray] Toy Car $10
[/tt]
I am using cr 9.

Thanks.
 
you can use something like this in the section expert under the background color:

iif(remainder(recordnumber,2)=0,crsilver,crwhite)

for every other line.
You might be able to create a grouping which would allow you to alternate every 2 lines...
 
do i have to generate the record number in the stored procedure?
 
... and can I highlight just the labels instead of entire section?
 
To highlight two records in a row or two consecutive (vertically) fields, create a formula {@counter}:

whileprintingrecords;
numbervar counter;

if counter < 4 then
counter := counter + 1 else counter := 1;

Place this in the details section and suppress.

If you want whole rows to be colored, go to format section->details->color->background color->x+2 and enter:

whileprintingrecords;
numbervar counter;

if counter in [1,2] then crsilver else crwhite;

If you only want certain fields colored, select one or more (by holding down the shift key) fields, right click, and choose format field (or objects)->border->background->x+2 and enter the above (second) formula.

-LB
 
this is so sweet.

I also added:
whileprintingrecords;
numbervar counter;

counter := 0;

to the group header so that that it starts with same color all the time.

Is there a list of all the colors? How can i build custom colors?
 
If you go into one of the color format formula sections, either in format section->color or format field->border, you will see a selection of colors under functions->color constants. You can also create custom colors by using the color function:

color(red,green,blue)//substitute a number from 0 - 255 for each color name within the parentheses

The numbers indicate the different values of each hue to be mixed together to create the custom color.

In the previous post, the formula would become something like this (for an intriguing purple!):

if counter in [1,2] then color(150,10,200) else crwhite;

-LB
 
this is somethign that should go to the faq
 
Create a function called Modline
Use this code which will give you alternate line coloring. [Change the 2 to a 3 for every third line etc.]

RecordNumber mod 2

Go to the details section in the report and then then format section option. Choose the Color TAB. Conditionally control this with this code

If {@Modline} = 1 then Silver Else White

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top