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

Graying alternative detail lines

Status
Not open for further replies.

HoosHot

Programmer
Jan 16, 2003
41
US
Hi,

I'd like to do alternative graying of my detailed data (for easier reading).

Here is some sample data:
id col1 col2 col3
-- ---- ---- ----
1 abc def ghi
2 bcd efg hik
2 bcd efg ikl
3 cde fgh ikl
3 cde ghi klm
3 def ghi lmn
4 abc def ghi

In this example, I want all the rows with id's of 2 to be grayed and all the rows with id's of 4 to be grayed.

I think I should do background color with a condition formula for the detail section, but I'm not sure how to code the formula.

Thanks a bunch!
mnguyen_va@yahoo.com
 
I'm sure there are several ways to do this, but since I just did this today here's one that will work:

You say you want to grey alternate lines, but your example shows multiple detail sections for each ID. In this case, conditionally format the section using the ID field:

if {id} in [2,4] then silver else white

More likely, if you really want alternating bands then you would create a variable and place it in the detail section:

whileprintingrecords;
numbervar counter;
counter := counter + 1

Then your conditional formula would be:

if {@counter} mod 2 <> 0 then silver else white

If your report has groups, then reset the counter for each group so that the first detail section is always grey. Put it in the group header:

whileprintingrecords;
numbervar counter := 0

Hope this gets you going.
 
Hi,

Thanks for replying. However, I'm not sure I understand what you are saying. You are correct in that I don't just want alternating colors for each row.

I want alternating colors each time my id changes. And, BTW, as my example shows, each id can contain one to many rows. In my above example, the row with id=1 would be white; the two rows with id=2 would be gray; the three rows with id=3 would be white; the one row with id=4 would be gray.

Thanks :)
 
I'm no expert, but on a similar line to dukeslater's response, why not try:

if {id} mod 2 <> 0 then silver else white

This way, if the id is 1, 3, 5, etc... it will be silver (grey), if it is 2, 4, 6, etc... it will be white.
 
You add another details line below your current details line. Then make the new section (details b) look exactly like the original (details a).

Format details a like this:
In the format window make sure details a is highlighted. Click the COLOR tabe and set the background color to white (or whatever you want).
Click the COMMON tab, put a check mark in the SUPPRESS (NO DRILL-DOWN) box, then click on the X-2 (formula) button to the right. In the formula box type the following:

Remainder(Recordnumber,2)<>0

Do the exact same thing for details b except the formula should be :

Remainder(Recordnumber,2)=0

This information should be in one of the help files under &quot;Alternating Background Colors for Rows.&quot;

Oliver

 
Hi All,

The reason why I can't do the &quot;remainder&quot; tip is my id's are not 1..x. I just did that for simplicity of explaining my situation. My id's are random alphanumeric.

id col1 col2 col3
--------- ---- ---- ----
n637252a9 abc def ghi
8djsksd8e bcd efg hik
8djsksd8e bcd efg ikl
xsgbchsl3 cde fgh ikl
xsgbchsl3 cde ghi klm
xsgbchsl3 def ghi lmn
2vbdgshdm abc def ghi

So again, in this example, I would like the 2 lines with id=8djsksd8e and the 1 line with id=2vbdgshdm to be grayed.

I just want to gray every other chunk of lines of data when the id's change.

Please help.

Thanks :)
mnguyen_va@yahoo.com
 
Add a &quot;Running Total&quot; field that counts the {ID} field, and set it to evaluate &quot;on change of Group&quot;. Now you can use the remainder of this running total field as described by olichap. Ken Hamady
Crystal Reports Training/Consulting and a
Quick Reference Guide to VB/Crystal (including ADO)
 
Hi Ken and Friends,

When you say &quot;Add a &quot;Running Total&quot; field that counts the {ID} field, and set it to evaluate &quot;on change of Group&quot;.&quot;, do mean:

1) EvaluateAfter(Count ({BILL_LINE_ITEM.FAX_TRANX_ID}))

2) BeforeReadingRecords;
Count ({BILL_LINE_ITEM.FAX_TRANX_ID})

3) WhilePrintingRecords;
Count ({BILL_LINE_ITEM.FAX_TRANX_ID})

4) WhileReadingRecords;
Count ({BILL_LINE_ITEM.FAX_TRANX_ID})

5) something else?

thanks for clearing up my confusion.

:)
--mnguyen_va@yahoo.com
 
Hi Ken and Friends,

Forget my previous email on how to do a running total. I figured that out.

However, after I figured out how to do a running total, then I did &quot;olichap&quot;'s suggesting for graying lines.

I totally understand what Ken and Oliver are saying. However, when I do a running total for the following example, the running total for n637252a9=1, 8djsksd8e=2, xsgbchsl3=2, 2vbdgshdm=1. Using the &quot;remainder logic&quot; as described above, n637252a9 is white, 8djsksd8e is gray, xsgbchsl3 is gray, 2vbdgshdm is white.

I need the line with id=n637252a9 to be white; I need the lines with id=8djsksd8e to be gray; I need the lines with id=xsgbchsl3 to be white; I need the line with id=2vbdgshdm to be gray.

Again, I need each chunk of detail lines to be a different color each time the id changes.

id col1 col2 col3
--------- ---- ---- ----
n637252a9 abc def ghi
8djsksd8e bcd efg hik
8djsksd8e bcd efg ikl
xsgbchsl3 cde fgh ikl
xsgbchsl3 cde ghi klm
2vbdgshdm abc def ghi

Thanks again...
--mnguyen_va@yahoo.com
 
Hi all!

I figure it out. When I did the running total, I needed to evaluate on change of field (id), not on change of group.

Thank you for everybody's help :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top