I have a problem calculating a formula using shared number variables and sub-reports. I have checked out FAQs and thread767-857392 but it still is not working properly.
I am running CR10 using a Stored Procedure in SQL 2005.
1. I define 3 shared variables in the detail section of my main report:
WhilePrintingRecords;
Shared NumberVar CurrFunding;
Shared NumberVar PrevFunding;
Shared NumberVar TotalPrevFunding;
2. I calculate shared NumberVar CurrFunding in the detail section of my main report:
WhilePrintingRecords;
Shared NumberVar CurrFunding := 0;
Shared NumberVar CurrFunding := {apsp_srptFundingChange;1.CorporateFunding1}+{apsp_srptFundingChange;1.CorporateFunding2}+{apsp_srptFundingChange;1.InternalFunding};
3. I calculate shared NumberVar PrevFunding in the detail section of subbreport1:
WhilePrintingRecords;
Shared NumberVar PrevFunding := 0;
Shared NumberVar PrevFunding := {apsp_srptFundingChangeSub;1.CorporateFunding1}+{apsp_srptFundingChangeSub;1.CorporateFunding2}+{apsp_srptFundingChangeSub;1.InternalFunding};
4. I place subreport1 in the detail section of my main report.
5. So shared NumberVar CurrFunding and PrevFunding are calculated for each detail line.
6. I calculate shared NumberVar TotalPrevFunding in the detail section of subreport2:
WhilePrintingRecords;
shared NumberVar TotalPrevFunding := Shared NumberVar TotalPrevFunding + (Shared NumberVar CurrFunding - Shared NumberVar PrevFunding);
7. I place subreport2 in the detail section of the main report
8. I display the value of shared NumberVar TotalPrevFunding in the report footer.
My problem is calculating TotalPrevFunding. When I first run the report the value is correct. When I re-run the report using the same parameters the value is out by 168.
For debugging purposes I have tried displaying TotalPrevFunding on each detail line to see how the field is being calculated. The field is calculated correctly until the final page when an extra value is added to it.
The report has one detail section.
Any help will be greatly appreciated as I have spent a considerable amount of time on this and feel I need fresh ideas.
Many thanks.
Saners.
I am running CR10 using a Stored Procedure in SQL 2005.
1. I define 3 shared variables in the detail section of my main report:
WhilePrintingRecords;
Shared NumberVar CurrFunding;
Shared NumberVar PrevFunding;
Shared NumberVar TotalPrevFunding;
2. I calculate shared NumberVar CurrFunding in the detail section of my main report:
WhilePrintingRecords;
Shared NumberVar CurrFunding := 0;
Shared NumberVar CurrFunding := {apsp_srptFundingChange;1.CorporateFunding1}+{apsp_srptFundingChange;1.CorporateFunding2}+{apsp_srptFundingChange;1.InternalFunding};
3. I calculate shared NumberVar PrevFunding in the detail section of subbreport1:
WhilePrintingRecords;
Shared NumberVar PrevFunding := 0;
Shared NumberVar PrevFunding := {apsp_srptFundingChangeSub;1.CorporateFunding1}+{apsp_srptFundingChangeSub;1.CorporateFunding2}+{apsp_srptFundingChangeSub;1.InternalFunding};
4. I place subreport1 in the detail section of my main report.
5. So shared NumberVar CurrFunding and PrevFunding are calculated for each detail line.
6. I calculate shared NumberVar TotalPrevFunding in the detail section of subreport2:
WhilePrintingRecords;
shared NumberVar TotalPrevFunding := Shared NumberVar TotalPrevFunding + (Shared NumberVar CurrFunding - Shared NumberVar PrevFunding);
7. I place subreport2 in the detail section of the main report
8. I display the value of shared NumberVar TotalPrevFunding in the report footer.
My problem is calculating TotalPrevFunding. When I first run the report the value is correct. When I re-run the report using the same parameters the value is out by 168.
For debugging purposes I have tried displaying TotalPrevFunding on each detail line to see how the field is being calculated. The field is calculated correctly until the final page when an extra value is added to it.
The report has one detail section.
Any help will be greatly appreciated as I have spent a considerable amount of time on this and feel I need fresh ideas.
Many thanks.
Saners.