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.
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?
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.
0
nobile00Author Commented:
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.
As he said, put the first formula in the Report Header, to initialize the variable.
Create the second formula, but do _not_ put it on the report.
Then use his last formula to set the color.
His instructions had you putting the second formula in the group header and using it in the color formula, which meant that it would be evaluated twice for each group header, increasing the count by 2 each time. If you don't put the second formula on the report and only use it in the color formula, I think that will work.
An alternative would be to put the second formula in the group header (only the group header where you want to change the color) and use the variable (not the formula) in the color formula. That way the variable is only incremented once for each group header. My problem with that is that if you increment the variable in a formula in the group header, and check the variable in a formula that sets the color for that group header, I'm not sure which formula will be evaluated first.
The first suggestion above was just going for what was closest to what you presumably already had - Just remove the second formula from the report, but leave it in the color formula. But if you feel like doing a bit more work, you could eliminate the second formula completely and just use this as the color formula:
Shared NumberVar gr_cnt;
gr_cnt := gr_cnt + 1;
if gr_cnt mod 2 = 0 then
crNoColor
else
{@ICONTeal}
James
0
nobile00Author Commented:
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}
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.
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.
The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.
One of a set of tools we're offering as a way of saying thank you for being a part of the community.
I use another way to solve this:
1. Create a formula with shared (or global if you like) variable
Shared NumberVar gr_cnt :=0;
True;
put it into report header and minimize it.
2. Create formula
Shared NumberVar gr_cnt;
gr_cnt := gr_cnt + 1
and place it into grop header where you want to have different color. I usually make them very tiny so you can't see it.
Now use that second formula instead of groupnumber.
In this case it will count just top-level groups and result should bre correct.
Probably not the best way but it works for me :)