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!

Subreport Subtotals in Main Report (CR v9) 1

Status
Not open for further replies.

ltidquist

MIS
Sep 28, 2007
45
US
I have read all of the previous posts on this topic and have followed the instructions to a 'T' and am still not getting the correct results hence this post....

I have a report in CR 9....
My main report includes company information in a group header and activity detail in the details section for a particular activity type. I have totalled this and it's working great.

I then had to add in a subreport to show a different activity for the companies and this is where my problems start. I created the subreport and created a variable called 'MyTotal' that looks like this:

whileprintingrecords;
shared currencyvar mytotal:= Sum ({Activity.AMOUNT})

I placed this is the report footer of the subreport. My subreport is linked to the main report by CompanyID. I put the subreport in the main report in a group footer and in the report footer of the main report I created a variable called TotalPayments and it looks like this:

whileprintingrecords;
shared currencyvar MyTotal;
MyTotal

When I generate the report the total that I get at the end of the report only shows the last payment that was reported in the subreport -- not all of them added together.

What in the world am I doing wrong? I've rewritten this report twice as well as tried putting the variables in a number of different sections.

Thanks in advance for any help I can get.
 
You need another field in the main report. Something like
Code:
whileprintingrecords;
currencyvar MyGrandTotal;
MyGrandTotal = MyGrandTotal + MyTotal

Put this in the group footer. Then display the result in the footer as
Code:
whileprintingrecords;
currencyvar MyGrandTotal;
MyGrandTotal
You could also probably do a summary total of the 'MyTotal' field in the main report.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 11.5 with SQL and Windows XP [yinyang]
 
When I add the formula:

whileprintingrecords;
currencyvar MyGrandTotal;
MyGrandTotal = MyGrandTotal + MyTotal

I get an error on the 'MyTotal' -- A Number, Currency Amount, Date, Time, DateTime or String is expected here.

I declared that the MyTotal was a currencyvar in the reports so I don't get it.

In the main report the MyTotal formula is like this:
whileprintingrecords;
shared currencyvar MyTotal;
MyTotal

Thanks again.
 
Place the following in a GFb footer (if the sub is in GFa):

whileprintingrecords;
currencyvar MyGrandTotal;
shared currencyvar MyTotal;
MyGrandTotal := MyGrandTotal + MyTotal; //note the colon

Then in the report footer use:

whileprintingrecords;
currencyvar MyGrandTotal;

I'm not sure whether the variable names are case sensitive, but I always try to use case consistently.

-LB
 
Thanks LB --

That got me closer as I am now at least getting a number but it's not adding it correctly. It finds the first payment activity and then continues to add that amount to the total until it finds another entry for that activity and then it adds that amount to it until the next one and so on.

Clear as mud? Any ideas?
 
What is incorrect about the result? You should be suppressing the accumulation formula and just looking for the correct result in the report footer. Do you have some null subreport values? If so, you need a reset formula in a section before the one containing the subreport, e.g., in the corresponding Group Header:

whileprintingrecords;
shared currencyvar MyTotal;
If not inrepeatedgroupheader then
MyTotal := 0;

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top