Gordon Hughes
asked on
Carry Data between 2 sub reports
I have a report where I want to carry data from 1 sub report to a 2nd sub report
Thought I was there with the following formula
WhilePrintingRecords;
Shared NumberVar MyValue2;
Shared StringVar Array loc_names;
Shared NumberVar Array loc_totals;
Shared NumberVar loc_count;
Local NumberVar i;
if {WOEQLIST.LOCATION} in loc_names then
(
// If LOCATION is in the loc_names array, find which entry it's in
// and then output the corresponding entry from loc_totals
for i := 1 to loc_count do
if loc_names [ i ] = {WOEQLIST.LOCATION} then
exit for;
loc_totals [ i ]
)
else
// If LOCATION is not in the loc_names array, just output 0
0
but it is not carrying all the figures forward as can be seen in the attached
Am sure it just requires a slight mod to the formula
Please help
Gordon
Carry-Forward-figures.pdf
Thought I was there with the following formula
WhilePrintingRecords;
Shared NumberVar MyValue2;
Shared StringVar Array loc_names;
Shared NumberVar Array loc_totals;
Shared NumberVar loc_count;
Local NumberVar i;
if {WOEQLIST.LOCATION} in loc_names then
(
// If LOCATION is in the loc_names array, find which entry it's in
// and then output the corresponding entry from loc_totals
for i := 1 to loc_count do
if loc_names [ i ] = {WOEQLIST.LOCATION} then
exit for;
loc_totals [ i ]
)
else
// If LOCATION is not in the loc_names array, just output 0
0
but it is not carrying all the figures forward as can be seen in the attached
Am sure it just requires a slight mod to the formula
Please help
Gordon
Carry-Forward-figures.pdf
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You need to also declare the shared variables in the main report otherwise there is no way carry the value through the main report from the 1st to the second subreport.
Since the subreports cannot communicate with each other directly the main report is used to carry the information from one to the other. If it has no where to save the information then it cannot be given to the 2nd subreport.
mlmcc
Since the subreports cannot communicate with each other directly the main report is used to carry the information from one to the other. If it has no where to save the information then it cannot be given to the 2nd subreport.
mlmcc
ASKER
Hi mimcc
I have addedthe 2 formulae
1 in the main report and 1 in the 2nd sub report
I still get the 0 values
Gordon
I have addedthe 2 formulae
1 in the main report and 1 in the 2nd sub report
I still get the 0 values
Gordon
Is the main report formula in the report header?
Are the 2 subreports working on the same database?
mlmcc
Are the 2 subreports working on the same database?
mlmcc
ASKER
Hi mimcc
I put the following in the main report
WhilePrintingRecords;
Shared NumberVar MyValue2;
Shared StringVar Array loc_names;
Shared NumberVar Array loc_totals;
Shared NumberVar loc_count;
And yes they all look at the same database
Gordon
I put the following in the main report
WhilePrintingRecords;
Shared NumberVar MyValue2;
Shared StringVar Array loc_names;
Shared NumberVar Array loc_totals;
Shared NumberVar loc_count;
And yes they all look at the same database
Gordon
Can you upload the rpt file?
mlmcc
mlmcc
ASKER
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Excellent responses and solutions as always
ASKER
James helped with this
In the 1st sub report there is:
WhilePrintingRecords;
Shared NumberVar MyValue2;
Shared StringVar Array loc_names;
Shared NumberVar Array loc_totals;
Shared NumberVar loc_count;
Local NumberVar i;
MyValue2 := Sum ({@NoDoneInPeriod}, {WOEQLIST.LOCATION});
if loc_count > 0 and {WOEQLIST.LOCATION} in loc_names then
(
// If LOCATION is in the loc_names array, find which entry it's in
// and then add the Sum to the corresponding entry in loc_totals
for i := 1 to loc_count do
if loc_names [ i ] = {WOEQLIST.LOCATION} then
exit for;
loc_totals [ i ] := loc_totals [ i ] + Sum ({@NoDoneInPeriod}, {WOEQLIST.LOCATION});
)
else
(
// If LOCATION is not in the loc_names array, increment the count,
// resize (Redim) the array to match (Preserve keeps the existing
// array contents), and put LOCATION and the Sum in the last entries
loc_count := loc_count + 1;
Redim Preserve loc_names [ loc_count ];
Redim Preserve loc_totals [ loc_count ];
loc_names [ loc_count ] := {WOEQLIST.LOCATION};
loc_totals [ loc_count ] := Sum ({@NoDoneInPeriod}, {WOEQLIST.LOCATION});
);
In the second report can only see
WhilePrintingRecords;
Shared NumberVar MyValue2;
Shared StringVar Array loc_names;
Shared NumberVar Array loc_totals;
Shared NumberVar loc_count;
Local NumberVar i;
if {WOEQLIST.LOCATION} in loc_names then
(
// If LOCATION is in the loc_names array, find which entry it's in
// and then output the corresponding entry from loc_totals
for i := 1 to loc_count do
if loc_names [ i ] = {WOEQLIST.LOCATION} then
exit for;
loc_totals [ i ]
)
else
// If LOCATION is not in the loc_names array, just output 0
0
Does this make sense or is something missing
Gordon