this becomes complex...
most of the time when you do a running total it's a total for a group, but here you want to have individual running totals by item, which is a bit more complex.
I have 2 possible solutions, neither of which is completely simple:
1) create a delimited string listing the item and its total which is maintained by adding/modifying the string
2) creating 2 arrays, 1 to hold the item and the second to holds it total
you may need to reset these methods as well, but from the snippet above, you wouldn't.
the delimited string would be something like |itemID^currentTotal|item^currentTotal|...
so you would use instr(totalString, "|" + {table.itemID} + "^") if this is > 0 then you would want to retrieve from initial pipe (|) to the next pipe and string current value, update it, display it, and then re-encode the value and insert it back into the string. If the instr() = 0 , then you would just encode and add to the string.
if you are using arrays, you would initially dim 2 arrays to a size that is large enough to hold the items, say 100 or so to start. (we can dynamically resize the array, but initially I would try to stay away from that). Then you would search one of the arrays for the itemID, and if you find it, you can look in the other array at the same index for the value, increment it, display it, and just update the array. If you don't find the itemID, you update the 'last' array element to hold the new itemID and update the count in the other array for the same index.
Neither is simple, but neither is it impossible.
HTH