I have a table with product purchases (Oper_dia), and when I sell (Oper_SocInv) I have to do with First In First Out (FIFO), and the quantity sold (opsi_titulos), is not identical to a purchase, so that have to sell the first purchase and the remaining cover with the second purchase, and if there are remaining with the third purchase, and so on
In the next image (form F_Oper_SocInv), you could see the inventory of the product, and the detail of each buy, also I have another subform with the sell operation (Operación).
With “Integra operaciones” I declare a global variable var1, and open the query Act_Oper_dia
With the global variable I can calculate the values for the first record, but I can not pass values to the second record, by updating the value of var1, or any other method.
Act_Oper_dia Fecha Títulos Precio Importe Tit_vta var1 Fecha Cmp 21/03/2012 -615.00 -29.16 -615 -6715 02/03/2012 21/03/2012 -16,389.00 -29.16 -7330 0 05/03/2012 23/03/2012 -52.00 -29.16 -52 -7278 08/03/2012
I need the follow result, where Tit_vta are the quantity sale by each previus buy
opd_fecha opd_titulos Precio opd_prec opd_impte Tit_vta var1 21/03/2012 -615 -29.1562 0 -615 -6715 21/03/2012 -16389 -29.1562 0 -6715 0 23/03/2012 -52 -29.1562 0 0 0
I send you the application
I appreciate your help