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

Incorrect value from subreport appearing in main report

Status
Not open for further replies.

morechocolate

Technical User
Apr 5, 2001
225
US
I have a subreport where I have a formula that subtotals on group footer 1 which is Table.Cusip. The formula is

WhilePrintingRecords;
Shared NumberVar CusipTotal := Sum({Table.Quantity},{Table.Cusip})

Running the report used for the subreport I can see the formula is working fine. In the main report in group footer 1 I have the following formula

WhilePrintingRecords;
Shared NumberVar CusipTotal;

I placed this formula in group footer 1 of the main report rather than showing the subtotal from the subreport it is showing the last record from the cusip group in the subreport.

I cannot figure out what the problem is.

Any ideas?

Thanks
 
Does this:

"it is showing the last record from the cusip group in the subreport."

mean that you get the last value for Sum({Table.Quantity},{Table.Cusip}) from the sub?

Did you link the subreport by the {Table.Cusip}?

If not, it may be that it's executing the entire sub and returning the last sum for the sub, rather than the one for that {Table.Cusip}.

-k kai@informeddatadecisions.com
 
Let me give a visual example

Subreport run by itself yields the following:

ABC 100 <--details
ABC 200
ABC 300
600 <--gf 1 all others suppressed

CDE 100
CDE 100
200

Main report

Alpha ABC 100
Alpha ABC 200
Alpha ABC 300
300 <--last record from details in subreport, I was expecting 600

Beta CDE 100
Beta CDE 100
100
 
I was able to solve the problem.

I changed
WhilePrintingRecords;
Shared NumberVar CusipTotal;

to

WhilePrintingRecords;
Shared NumberVar CusipTotal;
NumberVar TheTotal;
TheTotal := TheTotal + CusipTotal

and placed in the section below the supreport.

Then the following formula to GF1 of the main report to display the subtotal

NumberVar TheTotal;
TheTotal

and in GH1 I placed the following formula

NumberVar TheTotal := 0;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top