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!

How to have running total through main report + subreports.

Status
Not open for further replies.

StevenK

Programmer
Jan 5, 2001
1,294
GB
I have a report which contains two subreports.
Within each of these two subreports I have 'Quantity' fields (suppose we have ‘QTY1’ in the first subreport and ‘QTY2’ in the second).
Within the main report I have it grouped such that I output the details of the group and then within two separate detail bands I output subreports 1 and 2 respectively.
The two subreports are linked to a the main table report (the grouping field) such that I get a report layout as follows :

StockCode 1
SaleLine1 (StockCode1) - QTY1 = 3
SaleLine2 (StockCode1) - QTY1 = 8
SaleLine3 (StockCode1) - QTY1 = 6
QTY1 Sold = 17
BuyLine1 (StockCode1) - QTY2 = 12
BuyLine2 (StockCode1) - QTY2 = 32
QTY2 Bought = 44
Qty into Stock = (44 - 17) = 27 (StockCode1)

StockCode 2
SaleLine1 (StockCode2) - QTY1 = 200
SaleLine2 (StockCode2) - QTY1 = 120
QTY1 Sold = 320
BuyLine1 (StockCode2) - QTY2 = 150
BuyLine2 (StockCode2) - QTY2 = 66
BuyLine3 (StockCode2) - QTY2 = 14
QTY2 Bought = 230
Qty into Stock = (230 - 320) = -90 (StockCode2)

What I'm looking for is a means of starting the group with the total TOTAL1 (for the group) as being 0.
For each detail line in the first subreport I need to subtract the value of QTY1 from the value of TOTAL1, and for each detail line in the second subreport I need to add the value of QTY2 to the value of TOTAL1.
At the end of the grouping (after the two subreports) I need to output the value of TOTAL1 for the group.
On moving to the next grouping I then need to reset this TOTAL1 value back to zero.

How do I set about doing this ?
I'm assuming that I need to make use of Crystal variable(s) with the correct scoping - but am struggling to see where to start.
Where do I define the variable ?
What scoping do I need (shared / global) ?
How do I modify this value TOTAL1, either adding or subtracting from it ?

Any help would be greatly appreciated.

Thanks in advance
Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top