trying to accumulate conditionally summed variables in a group footer,and summary
I followed the Tech-tips "Calculating a Summary based on Group Totals" first
example; My results, however are bad (every accumulator ends up with a value
of 0)
I have a sub-report with 3 groups, and no visible detail. In the middle
group (i.e. groups[1]), I conditionally
sum a detail value (as in the tech-tip "Calculating a Summary based on Group
Totals") for a variable called "varParentIDAmount", and I want to accumulate
the values of those sums for each group, as the value of a variable
(varContactIDTotal) shown in the outer-most group footer (i.e. groups[0]).
Also, I want to accumulate the same values over the whole sub-report, as the
value of a variable (varTotal) within the summary band.
here is genericized code from the onCalc event of the variable from
groups[1] (i.e.varParentIDAmount):
if (sClassID = aValue)then begin
Value:=Value+TableName['Amount']
varContactIDTotal:=varContactIDTotal+TableName['Amount'];
varTotal:=varTotal+TableName['Amount'];
end else begin
Detail.Visible:=False;
end;
T:iming
1) Initial variable(varParentIDAmount) is: calculate on:Traversal, reset
on: GroupEnd, reset group: Groups[1]
2)1st Accumulator(varContactIDTotal--in the outermost group)is: calculate
on: Traversal, reset on: GroupEnd,
reset Group: Groups[0]
3) 2nd Accumulator(varTotal--in the summary) calculate on: Traversal reset
on: ReportStart
I put a seried of showmessages in the OnCalc event to check values as the
report is running, with the results:
1) the variable of each accumulator starts at 0;
2) the amount (e.g. PaymentApplications['LedgerAmount']) to increment each
accumulator is a positive value, as expected;
3) after the addition of the accumulator's value(0) and the amount (i.e.
after lines 3, 4 from code snippet above), the accumulators' values remain
0.
Does anyone know why the accumulators won't accumulate, or what I'm doing
wrong?
Thanks in advance,
Brian
example; My results, however are bad (every accumulator ends up with a value
of 0)
I have a sub-report with 3 groups, and no visible detail. In the middle
group (i.e. groups[1]), I conditionally
sum a detail value (as in the tech-tip "Calculating a Summary based on Group
Totals") for a variable called "varParentIDAmount", and I want to accumulate
the values of those sums for each group, as the value of a variable
(varContactIDTotal) shown in the outer-most group footer (i.e. groups[0]).
Also, I want to accumulate the same values over the whole sub-report, as the
value of a variable (varTotal) within the summary band.
here is genericized code from the onCalc event of the variable from
groups[1] (i.e.varParentIDAmount):
if (sClassID = aValue)then begin
Value:=Value+TableName['Amount']
varContactIDTotal:=varContactIDTotal+TableName['Amount'];
varTotal:=varTotal+TableName['Amount'];
end else begin
Detail.Visible:=False;
end;
T:iming
1) Initial variable(varParentIDAmount) is: calculate on:Traversal, reset
on: GroupEnd, reset group: Groups[1]
2)1st Accumulator(varContactIDTotal--in the outermost group)is: calculate
on: Traversal, reset on: GroupEnd,
reset Group: Groups[0]
3) 2nd Accumulator(varTotal--in the summary) calculate on: Traversal reset
on: ReportStart
I put a seried of showmessages in the OnCalc event to check values as the
report is running, with the results:
1) the variable of each accumulator starts at 0;
2) the amount (e.g. PaymentApplications['LedgerAmount']) to increment each
accumulator is a positive value, as expected;
3) after the addition of the accumulator's value(0) and the amount (i.e.
after lines 3, 4 from code snippet above), the accumulators' values remain
0.
Does anyone know why the accumulators won't accumulate, or what I'm doing
wrong?
Thanks in advance,
Brian
This discussion has been closed.
Comments
2nd method from Tech-tips.
This gives me values other than 0 for the accumulators (see parent message),
but they are
wrong. It appears that in some groups, the values are doubled, so I changed
the code from
Value:=Value+varParentIDAmount.Value
to
if Report.SecondPass then
Value:=Value+varParentIDAmount.Value
end;
to prevent the values from being accumulated twice.
This, however, resulted in 0 values for all accumulators. (I tried
"subreport1.SecondPass", but the compiler didn't like it).
Anyone know what to do?
Thanks in advance,
Brian
certainly cause a value of zero when calculating.
If a TppVariable has its reset group set, then for every group that finishes
printing, the variable's value gets reset back to zero. You may want to use
another TppVariable in the group footer that doesn't have a reset group
assigned, so it will calculate a running total for all of the groups that
print.
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
That was one of the first things that occurred to me, as well, but the
variables (all of them) are of type currency.
How does one specify that a particular line of code in a sub-report is
executed only on the second pass?
if (Report.SecondPass) doesn't seem to do it...
Brian