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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Having problems with using shared variables for subreport totals

Status
Not open for further replies.

css1015

Programmer
Oct 29, 2003
20
0
0
US
Hi,

I have 2 subreports each of which has a Month-to-date (MTD) total stored in a shared variable. The subreports occupy different sections in the detail section of the main report. I need to total the subreport totals in the main report.


SUBREPORT I:
Formula field name 'SharedMTDVisitorPermitRVSum'

Code for subreport MTD total 1:
Shared NumberVar MTDVisitorPermitRVSum;
MTDVisitorPermitRVSum := Sum ({@MTDVisitorVendorPermits}) + Sum ({@MTDRV});


SUBREPORT II:
Formula field name 'SharedMTDCoinGateSum'

Code for subreport MTD total 2:
Shared NumberVar MTDCoinGateSum;
MTDCoinGateSum := Sum ({@MTDParkingDeckCoinGate});


MAIN REPORT TOTAL FIELD:
Formula field name 'OtherRevenueMTDTotal'

Code for main report total:
WhilePrintingRecords;
Shared NumberVar MTDVisitorPermitRVSum;
Shared NumberVar MTDCoinGateSum;

MTDVisitorPermitRVSum + MTDCoinGateSum;

I always get a value of zero returned in the main report. The subreport totals are non-zero values that display correctly. How do I correct this? What is wrong with my main report total / subreport totals? I substituted the word 'Shared' with 'Global', still the same results.

Any help would be appreciated. Thanks in advance.

Chad
 
Using "Shared" is correct. You must place the main report formula that adds the two shared variables in a section below the ones where the subreports are located. If they are in detail_a and _b, then insert a section detail_c and place the formula there. If you then want to accumulate this total at a group or report level, you will need to add a new variable in the main report to accomplish this. If you want help with that, you need to provide information about your main report structure, where subreports and formulas are located, and where you want totals.

-LB
 
Hi lbass,

I also have other subreports that are not needed for this total. They are in detail_a, detail_b, detail_e, and detail_f.

The subreport totals that I need - those subreports are in detail_c and detail_d. I inserted a section below all the subreports and am placing my main report formula field in detail_g below all subreports. That is all the totalling that I need. I don't need to accumulate this main report variable further.

Hence I am not able to figure out what is going wrong with the main report variable. Any other suggestions?

Thanks again.

Chad

 
Did you place your shared variable formulas in the report footers of each subreport? The formulas have to be placed on the subreport to be shared with the main report.

-LB
 
No, I had not placed my shared variable formulas in the report footers of each subreport. But I did now, however the resut was the same, the individual subreport variable formulas turn out to be just fine. The main report still shows a zero value.

Chad
 
I'm not sure--but try adding "whileprintingrecords" to the beginning of each shared variable formula within the subreports.

-LB
 
That did it!!! I added 'WhilePrintingRecords' at the beginning of each shared variable formula within the subreports. The total came up right and worked perfectly. Thank you so much.

Chad
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top