I am trying to create a running total in a query. I googled and found something using DSUM, it appeared to be what I wanted but I only get #Error in the field, not running totals.
I want to have a running total for each InvtID that resets on each new InvtID. The InvTranQuery totals by InvtID and TranDate so these are all unique records.
Here is the SQL query I have:
SELECT [InvTran Query].InvtID, [InvTran Query].TranDate, [InvTran Query].SumOfQty, DSum("[SumOfQty]","InvTran Query","[InvtID]=" & [InvtID] & " And [TranDate] <=#" & [TranDate] & "#") AS RSum
FROM [InvTran Query]
ORDER BY [InvTran Query].InvtID, [InvTran Query].TranDate;
Results wanted:
WID1 01/01/2017 10 10
WID1 01/02/2017 20 30
WID1 01/05/2017 -5 25
WID2 01/01/2017 15 15
WID2 01/03/2017 -3 12
WID3 01/05/2017 11 11
WID3 01/06/2017 -2 9
I want to have a running total for each InvtID that resets on each new InvtID. The InvTranQuery totals by InvtID and TranDate so these are all unique records.
Here is the SQL query I have:
SELECT [InvTran Query].InvtID, [InvTran Query].TranDate, [InvTran Query].SumOfQty, DSum("[SumOfQty]","InvTran Query","[InvtID]=" & [InvtID] & " And [TranDate] <=#" & [TranDate] & "#") AS RSum
FROM [InvTran Query]
ORDER BY [InvTran Query].InvtID, [InvTran Query].TranDate;
Results wanted:
WID1 01/01/2017 10 10
WID1 01/02/2017 20 30
WID1 01/05/2017 -5 25
WID2 01/01/2017 15 15
WID2 01/03/2017 -3 12
WID3 01/05/2017 11 11
WID3 01/06/2017 -2 9