Are you trying to accumulate all the totals into one Batch total to add back into the main report? In that case do
Shared numbervar Batch := Batch +
Sum ({Tkbatch.Qty}, {Tkbatch.Qty})
In your subreport.
If you want three batch totals back in your main report, do
Shared numbervar Batch1;
Shared numbervar Batch2;
Shared numbervar Batch3;
If {table.group} = "Group1" then
Batch1 :=Sum ({Tkbatch.Qty}, {Tkbatch.Qty}) else
If {table.group} = "Group2" then
Batch2 :=Sum ({Tkbatch.Qty}, {Tkbatch.Qty}) else
If {table.group} = "Group3" then
Batch3 :=Sum ({Tkbatch.Qty}, {Tkbatch.Qty}) ;
The problem of course is what to do if the subreport has four groups, or more. A lot of groups require a different technique.
Treat the subreport as a stand alone summarised action in the main report. The subreport has to do ALL it's work, before it returns to the main report to continue processing. Then if the section is processed again, the subreport has to do it all again. You have to design your report on both levels: Main Report and Subreport.
Explain in more detail what they are both doing and what you really want the shared vairble to do.
Editor and Publisher of Crystal Clear