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!

Running Total using group header value plus detail 1

Status
Not open for further replies.

Luvsql

Technical User
Apr 3, 2003
1,179
CA
I must be having a brain f*&t. I have a group header "Item" which has a number value. I then have details. I need to create a running total that adds the value from the group header to the value in the detail, display it, then repeat it for all the records in the detail for that item.

 
Do you literally mean you want to sum the item field with the detail field? If you are grouping on {table.item}, then it will recur in each detail field. You can create a formula:

{table.item}+{table.detail}

Then use a running total to sum this (or if you don't need to see the total as it sums, you could just insert a sum on it at the group/and or grand total level.

-LB
 
Here is my data structure. TableA had Item and TotalQty field. I have grouped the report on TableA.Item and added the TotalQty field onto it (it's not a sum as it is a single value per item). I then linked this to TableB on the Item field (this table has multiple values per Item). I added TableB.DetailQty to the report.

What I would like is a running total after each detail.

Table A

Item1 100

Table B

Item 1 (4)
Item 1 8
Item 1 (1)

The report would print:

Item 1 100
(4) 96
8 104
(1) 103

I tried adding the TableA.TotalQty + TableB.DetailQty and then creating a running total on it, but the first record works, but then the second is adding the TableA.TotalQty again to the second value.
 
Place this in the Item group header:

whileprintingrecords;
numbervar Aqty := maximum({TableA.Qty},{TableA.ItemID});
numbervar sumdet := 0;
Aqty

Place this in the detail section:

whileprintingrecords;
numbervar Aqty;
numbervar sumdet := sumdet + {TableB.qty};
Aqty - sumdet

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top