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!

Shared Variable - sub to main report Totals 2

Status
Not open for further replies.

Lanie

Programmer
Jan 20, 2000
83
US
Good Morning,

Using v8.5

I must admit that I am clueless regarding shared variables, and not sure where to start.

I have a main report and a subreport. The main and subreport grouping is on District, each sum the sub total dollars in each district.

The main report (district AS for example) holds all new records with $$ sub total, and the sub report (same district) holds all "changed" records with $$ sub-totals.

There are four districts.

How would I get the total by districts onto the main report?

And finally, it needs a grand total for all of it on the main page.

After reading many of the threads here, I am totaly confused.

Thanks for your patience and assistance, in advance.



Lanie
etroidl@tampabay.rr.com
etroidl@conaxfl.com


 
I am assuming your subreport is placed in group footer 1 which is "District". That being the case, in your subreport create a formula and place it in group footer 1:
// {ChangedDistTotals}
WhilePrintingRecords;
Shared NumberVar ChgDistTot:= Sum({Table.Field},{Table.District})

Next create a formula to reset your shared variable to zero and place it in the subreport Report Header:
// {ChangedDistTotalsReset}
WhilePrintingRecords;
Shared NumberVar ChgDistTot:= 0

In your main report create a formula that declare the same shared variable, but do not set a value. Place this formula in a section below the subreport:
// {ChangedDistTotals}
WhilePrintingRecords;
Shared NumberVar ChgDistTot;

The formula containing the shared variable in the main report can be use in other formulas to calc totals etc.

MrBill
 
MrBill,
Thanks I will give it a try and let you know what happens.
Lanie

Lanie
etroidl@tampabay.rr.com
etroidl@conaxfl.com


 
Good Morning,

I've put done the forumals exactly as MrBill suggested above and it is returning zeros.

I then tried to sum up the {ChangedDistTotals} that is now on the main report, using a formula as well as the wizard. No dice. Guess I "really" don't get it.

Help!
Lanie





Lanie
etroidl@tampabay.rr.com
etroidl@conaxfl.com


 
You should have the subreport linked to the main report on district. Place the shared variable formula in the subreport footer. It can read like:

WhilePrintingRecords;
Shared NumberVar ChgDistTot:= Sum({Table.Field});

I would also place the shared variable reset formula in the main report in a GH#1 section, to allow for null subreports. Place the formula where you use the shared variable in your main report (you don't need to otherwise declare it) in GF#1_b:

whileprintingrecords;
shared numbervar chgdisttot;
numbervar addchgdisttot := addchgdisttot + chgdisttot;

Then place the following in the report footer:

whileprintingrecords;
numbervar addchgdisttot;

If you wanted to add the chgdisttot to the main report group total and then sum those results, then your formula would be:

whileprintingrecords;
shared numbervar chgdisttot;
numbervar sumall := sumall + chgdisttot + sum({table.amt},{table.district});

The report footer formula would be:

whileprintingrecords;
numbervar sumall;

I think the key thing is to put the shared variable in the subreport report footer instead of the group section.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top