Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Summing a Shared Variable in the Main Report 1

Status
Not open for further replies.

kime1974

Programmer
Oct 30, 2006
36
US
I have included a shared variable in my subreport and have also included it in my main report. Everything is great and I am able to perform a calculation with the shared variable by group.

However, I want to grand total in the report footer for each column - of which one is my subreport, a field in the main report and a formula to subtract my shared variable from a field in the main report.

I tried to write a sum based on the shared variable formula in the main report and have struck out. Any thoughts??

Thanks!
Kim
 
You can use variables to accumulate shared variables in the main report. Your description is confusing, but generically you would do something like the following to accumulate x for a grand total:

//{@accum} to be placed in the section where x is displaying:
whileprintingrecords;
shared numbervar x;
numbervar y := y + x;

//{@display} to be placed in the report footer:
whileprintingrecords;
numbervar y;

-LB

 
A tad unclear yet, you might try posting examples in the future, but here's some theory that should get you by.

In the main report formula where the shared variable is returned from the subreport, add in another variable to handle the aggregate, as in:

whileprintingrecords;
shared numbervar MySubreportValue;
numbervar MyAggregateValue;
MyAggregateValue:= MyAggregateValue+({maintable.value-MySubreportValue);

As you can see, now we have another variable which will maintain an aggregate of a main table value less the value returned by the subreport.

Then in the report footer you can display using:

whileprintingrecords;
numbervar MyAggregateValue

Hopefully this resolves.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top