Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Trouble restarting a variable once the group chang Post Reply Post New Topic
Author Message
otto
Groupie
Groupie


Joined: 17 Mar 2014
Online Status: Offline
Posts: 53
Quote otto Replybullet Topic: Trouble restarting a variable once the group chang
     Posted: 18 Mar 2014 at 5:47am
I have to groups in CR 2013, on the details I did a summary for the first group, then for the second one I place a shared variable on the first group and I sum the 1st group value each time it changes. I initialized that var in 0 in the 2nd group in order to restart the var every time the 2nd group changes. That works fine if the 1st group fix just one page, but if is change to a 2nd page I got the var restarted to 0. Can somebody help me please?
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 21 Mar 2014 at 5:13am
I think that i am confused.

I am thinking that the groups are like this:
gh1
gh2
details
gf2
gf1

and your description doesn't make sense.

are you referencing a layout like:
gh2
gh1
details
gf1
gf2

if you reset the variable in gh1, and you are printing the group header on every page, then yes your variable will reset.

if that is occurring, you could reset the variable in the group footer...since that will only print once per group regardless of how many pages the group spans.

At least it is worth a try

HTH
IP IP Logged
otto
Groupie
Groupie


Joined: 17 Mar 2014
Online Status: Offline
Posts: 53
Quote otto Replybullet Posted: 21 Mar 2014 at 5:22am
my bad, I described like your 2nd layout. If I put the the reset variable in the group footer the summaries field on the 2nd group is going to be populating correctly, but due to that 2nd group has different values the variable is not restarting in the next iteration.
for instance:
facility 1 has in and out groups inside, once it change to facility 2 it is summarizing facility 1 out with facility 2 in.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 21 Mar 2014 at 5:30am
hm...
this is how i would have set up my variables, keeping in mind the page spanning...and using the second layout

report header initialize the variables
gf1, increment the variable
gf2, display the variable and reset it.

so when group2 starts it always has a value of 0, when it ends it has the total of the groups inside it.

at least that is how it should work...
IP IP Logged
otto
Groupie
Groupie


Joined: 17 Mar 2014
Online Status: Offline
Posts: 53
Quote otto Replybullet Posted: 21 Mar 2014 at 5:34am
you are right, this is the way how it should works but for some reason it is not restarting the value for the next iteration.
thanks a lot for your answer, it is really appreciated   
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 21 Mar 2014 at 5:38am
well, the basic debugging of formulas is what I would try next.

I would display the value of the shared variable in the group header and the details lines (or where ever it is being incremented) to see if it is incrementing as expected.

If it is not incrementing as expected, I would start debugging the logic used to increment.

Since CR is such a black box, I tend to start breaking down my formulas into little pieces to see where my idea of what is happening differs from CR.

HTH
IP IP Logged
otto
Groupie
Groupie


Joined: 17 Mar 2014
Online Status: Offline
Posts: 53
Quote otto Replybullet Posted: 21 Mar 2014 at 5:42am
ok, I will try that and I would let you know the results.
thanks again
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum