Print Page | Close Window

Highlighting Every Other Line

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=3106
Printed Date: 18 Apr 2024 at 6:20pm


Topic: Highlighting Every Other Line
Posted By: motoxracer400f
Subject: Highlighting Every Other Line
Date Posted: 06 May 2008 at 7:39am

Hi, I've tried playing around with this for a while and can't figure out how to do it.

How do you stripe / highlight every other detail line of printed data with a color for easier reading like a formal document.
 
Thank you!!Smile



Replies:
Posted By: TheReportGuy
Date Posted: 06 May 2008 at 1:18pm
use a mod formula for the background colour in the details section


Posted By: motoxracer400f
Date Posted: 07 May 2008 at 5:43am
What is the formula to use?


Posted By: BrianBischof
Date Posted: 07 May 2008 at 10:22am
I cover this in Tutorial 6.14 of my Encyclopedia book. You can use this formula to assign the appropriate color to a section.
If (RecordNumber Mod 2 = 0) Then
    crSilver
Else
    DefaultAttribute;

You can find out more about my books at http://www.amazon.com/exec/obidos/ASIN/0974953601/bischofsystem-20 - Amazon.com or reading the http://members.crystalreportsbook.com - Crystal Reports eBooks online.


-------------
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>


Posted By: motoxracer400f
Date Posted: 07 May 2008 at 10:30am
Thanks for the very fast response.  I will have to check out your book.
 
I tried that formula and it works but the problem is that I am using a formula in the suppress field of the details section expert to remove/hide duplicates and inactive items so now it highlights random lines and not every other one.
 
What can I do to get it to evaluate this after the other fields are suppressed if you know what I mean?
 
Thanks again!


Posted By: BrianBischof
Date Posted: 07 May 2008 at 12:25pm
In that case, create a variable within the suppress fields formula which increments a counter only if the section is displayed (and make the variable Global). Then use this variable in the formula that I originally posted.
 
I think that should take care of you!


-------------
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>


Posted By: motoxracer400f
Date Posted: 08 May 2008 at 7:11am
Sounds like it will work, I'm just getting syntax errors trying to get this to work.  Were should I declare the variable and how do I word it in the declaration and in the formula.  I'm not very good at the crystal language because I try to write it out like visual basics and things don't line up well.  Can you please help me out with the formula a bit?
 
This is the code I am using in the suppress field:
 
global numbervar x;
 
if next({RFQ.RFQ}) = {RFQ.RFQ} then true
else if {RFQ.RFQ} = "TEST" then true
else
false and x = x + 1
 
Thank you so so much, I really appreciate it!


Posted By: Lugh
Date Posted: 08 May 2008 at 8:34am
The syntax error is the "and" bit.  It should look like:

if next({RFQ.RFQ}) = {RFQ.RFQ} then true
else if {RFQ.RFQ} = "TEST" then true
else
(false;
x = x + 1;)



Posted By: motoxracer400f
Date Posted: 08 May 2008 at 10:42am
I just can't figure this darn thing out.  All of the records are highlighted now.  Here are the formulas I'm using:
 
This is what I am putting in the Suppress of the details section:
 
global numbervar x;
if next({RFQ.RFQ}) = {RFQ.RFQ} then true
else if {RFQ.RFQ} = "TEST" then true
else(false;x = x + 1;)
 
This is what I am putting in the Backround Color of the details section:
 
global numbervar x;
If (x Mod 2 = 0;) Then    crSilver
Else    DefaultAttribute;


Posted By: Lugh
Date Posted: 09 May 2008 at 4:43am
Try putting a carriage return after the "false;" bit.  Crystal gets cranky when you put a line end marker (the semicolon) in the middle of the line.  It may be ignoring the instruction to increment x.




Posted By: motoxracer400f
Date Posted: 09 May 2008 at 5:31am
Still No-Go... Cry


Posted By: imstillfishing
Date Posted: 10 May 2008 at 6:47am
I achieve this by using a shared varable. Not as complicated as other methods, and probably not the bes way, but that is how I know to do it.
I explained my method in another post about alternating footer colors.
 


Posted By: Savan
Date Posted: 12 May 2008 at 4:38am
the other easy way is to put a running total field  say "x"  (type of summary is count) in the detail section and supress it, and use this value for formatting
 
If (x Mod 2 = 0;) Then  
  crSilver
Else
    DefaultAttribute;


-------------
Thanks
Savan


Posted By: motoxracer400f
Date Posted: 20 May 2008 at 6:40am
I created a running totals field called "X" and it worked!  Thank You!!  Big%20smile
 
This is what I did to achive the results if anyone is wondering:
 
I used the following formula in the "backround color" of the "details section":
 
If ({#X} Mod 2 = 0;) Then
    crSilver
Else
    DefaultAttribute;
 
Then, to get rid of the duplicates, in the running totals field I put a code in the "evaluate" / "use a formula" box of the following:
 
if next({RFQ.RFQ}) = {RFQ.RFQ} then false
else true


Posted By: Trishuli
Date Posted: 05 Jul 2010 at 5:57pm

1. Go to section expert

2. Select your details section
 
3. Select COLOR tab (not COMMON)
 
4. Put in the formula
 
    If (RecordNumber Mod 2 = 0) Then crSilver
    Else DefaultAttribute;


Posted By: motoxracer400f
Date Posted: 06 Jul 2010 at 5:16am
Thanks!



Print Page | Close Window