Link to home
Start Free TrialLog in
Avatar of nobile00
nobile00

asked on

Alternating Colors Issue Crystal Reports

Hi All

I am having an issue with alternating colors in a Crystal Report.  I have several groups and the alternating colors formula is in Group six the formula I am using is:

if groupnumber mod 2 = 0 then
   crNoColor
else
{@ICONTeal}

However, it's works fine on pages 1 and 2 then it gets funky on page 3 where it highlights 2 rows with the same color then 2no color then 6 with color 1 without.  

Is there something wrong with the formula or is there a different formula I should use so that the shading is consistent throughout the report.

Any help greatly appreciated.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of vetaldj
vetaldj
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nobile00
nobile00

ASKER

Thanks for your help.

I created the 2 formulas and placed them in the report.  I am not too clear about the last part how would the formula look without using groupnumber?

if <put second formula name here> mod 2 = 0 then
   crNoColor
else
{@ICONTeal}
Thanks

The formula for the colors looks like this:

if Shared NumberVar gr_cnt;
gr_cnt := gr_cnt + 1 mod 2 = 0 then
crnocolor
else {@ICONTeal}

but I am receiving an error it highlights the semicolon on the first line and indicates keyword 'then' missing.  Do I need to put parentheses around the first part of the formula or am I missing something?

Thanks for your help
Ok, you create 2 formulas, like
{@Formula1} :
   Shared NumberVar gr_cnt :=0;
   True;

and
{@Formula2}:
    Shared NumberVar gr_cnt;
    gr_cnt := gr_cnt + 1
 
Saved both and placed {@Formula1}  into Report Header and {@Formula2} into group header.
Then you need to modify your color formula to this:

if {@Formula2}  mod 2 = 0 then
crnocolor
else {@ICONTeal}

Sorry that I was not clear from the beginning.
Ok I did all the above and I am still having an issue with the colors in one section which is in the middle of the report.  page 1 and 2 are fine page 3 and part of 4 not page 5 and 6 fine.


do you by the chance suppres some groups based on some conditions?
The data that needs to be alternating is in group 6 and group 1 is not suppressed but groups 2 through 5 are suppressed.
Any other suggestions to get the alternating colors to display correctly.

Thanks in advance
Avatar of Mike McCracken
How are you suppressing the groups?

mlmcc
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I tried both eliminating the second formula from the group header but I get the same result not alternating on all pages.  I tried using the following formula without any other formula in the report header or group header still not alternating colors through out.


Shared NumberVar gr_cnt;
gr_cnt := gr_cnt + 1;

if gr_cnt  mod 2 = 0 then
  crNoColor
else
  {@ICONTeal}
Could you post the report?

mlmcc
I just tried it here and the basic idea works fine.

 What is @ICONTeal?  Could it be changing your colors?  You could try replacing it with a color, like crTeal.

 Where, exactly, did you put that formula?  I assume that it's setting the bg color for a group header section?  Is it only in one GH section?

 As mlmcc suggested, you could post the report.  Sometimes there are things that just don't become clear until we see the report for ourselves.

 James
Attached is the report that I am working on.  You will see on page three the alternating colors is not working.  Also, @ICONTeal is RGB(220, 250, 250).

Thanks for all your help Invoice-ICOLIMSData112210.rpt
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
FWIW, I agree with mlmcc.  You were sometimes suppressing GH6, but obviously CR is still evaluating the color formula for GH6 even when the section is suppressed, so the count was thrown off.  Changing the color formula to only increment when the section will not be suppressed seems to fix it.

 James
I believe Crystal firt "creates" the section then determines if you need to suppress it.  Thus the formulas all execute even though the section is eventually suppressed.

mlmcc
Thanks to all everything is working great!!
You're welcome.  Glad I could help.

 James