Pivot Table report sub-total recalcualation

Pivot Table report sub-total recalcualation

Hi,

I have a simple application to manage a warehouse for an ONLUS that provide food to poor people.

We are obliged to maintain a warehouse report in a specific format

Each time a new product go IN or OUT we add an entry with:

OPERATION DATE: date of opertation
PRODUCT: name of product
IN: quantity in
OUT:quantity out

the report must have  a row for each OPERATION DATE  in the below format


OPERATION DATE_________PRODUCT 1_________|________PRODUCT 2_____
                            |    IN        |    OUT      |  STOCK   |    IN        |    OUT      |  STOCK |


I calculate the STOCK each time a FORM is compiled and this works since the operation are done in sequence

I used the Pivot Table to create the report

The problem is that if I have to correct an old operation the STOCK values become completely wrong

A solution should be to recalculate all the STOCK anytime a FORM is loaded.

So the logical operation should be:

ON LOAD

fetch all the record sort by OPERATION DATE
for all the PRODUCT TYPE   STOCK=STOCK of the previous record + IN - OUT

Unfortunately I do not know how to implement it.
Could you please help me?

Thank you
Giovanni