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

How to alternate background color on every other line 11

Status
Not open for further replies.

AssetRecovery

Programmer
Sep 17, 2003
14
US
I need to format some reports that have long lists of information and it would make them alot easier to read if I could format the background color to alternate everyother line like in templates. What would a sample formula for this look like?
 
In the color attribute of the section format options enter something like:
-----------------------------------------------------
IF Remainder (RecordNumber, 2) = 0 THEN crYellow ELSE crNoColor
-----------------------------------------------------

Cheers,
- Ido

CUT, Visual CUT, and DataLink Viewer:
view, e-mail, export, burst, distribute, and schedule Crystal Reports.
 
That worked great but now how would I make the font be a different color on the lines that are yellow. I modified the formula so that I was using crTeal and it's hard to read black text on that background. Unless there is a way for me to specify the hex equiv for a lighter shade or am I stuck with just color names like Blue, Red, Yellow?

Thanks
 
You can use Color() and supply the RGB values, like this:
Code:
IF Remainder (RecordNumber, 2) = 0 THEN Color (238, 238, 224)
ELSE crNoColor

-dave
 
All of the named Colors will be in the function panel under the Color Constants.

Teal is one of the named colors.

IF Remainder (RecordNumber, 2) = 0 then teal else defaultattribute





Mike
 
Thanks fellas this used to be in a FAQ somewhere but it's disappeared. Very Handy
 
Also. If your getting multiple returns for each record and want every group to alternate colors is there a way to do that?
 
Answered my own question. Use GroupNumber instead of RecordNumber in 9.0
 
slightly different way, but just swap RecordNumber for GroupNumber

if GroupNumber mod 2 = 0 then
color (232,232,232)
else
white



Gary Parker
Systems Support Analyst
Manchester, England
 
Dear NovellCRDeveloper,

Here is a tip I show in my classes:

If you have suppressed groups or details, then using groupnumber or recordnumber will not work.

Create a running total (Insert Field Object/Running Total) and choose the Group or Detail field as the case may be. Select Count, Evaluate on Change of Record, Reset Never.

Now you have a counter field that counts the "visible" records and you would use that in the formula.

Now, to get the rgb value for any color, simply select format/font on any field, go all the way down the list to custom and then in the Custom Color Dialog select any color you want - the rgb value will display for you to note.

I find that a very light gray works really well.

Also, by changing the divisor to another number you can change the banding.

I hope the above was helpful,

ro

Rosemary Lieberman
rosemary@microflo.com, Microflo provides expert consulting on MagicTSD and Crystal Reports.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top