Hi Everyone!
Im really new user of Access so i think i need a litle of help to do this macro.
I have the following Table1:
Type Date Product Quantity Unit_Cost Total_Cost one 2014/10/01 A 2 1000 2000 two 2014/10/01 A 3 1100 3300 one 2014/10/02 A 2 1000 2000 X 2014/10/03 A 2 two 2014/10/01 B 2 1000 2000 one 2014/10/02 B 2 1000 2000 X 2014/10/04 B 3
what i need is run a macro who fill the data when the Type = "X"
the value of Unit_Cost will be =sum(Unit_Cost)/sum(Quantity) where Product is equal to "A or B" and Date < Date_of_AorB
I try to do a macro with this info, but do nothing..
For each record in Table1
where condition = [Table1].[Type] = "Sale"
SetLocalVar
Name varProd
Expression = [Table1].[Product]
SetLocalVar
Name varDate
Expression = [Table1].[Date]
SetLocalVar
Name varCost
Expression = [Table1].[Unit_Cost]
For each record in Table1
where condition = [Table1].[Product] = varProd
SetLocalVar
Name varCost
Expression = varCost + [Table1].[varCost]
Edit Record
SetField Unit_Cost
value = [varCost]
(yes i know that is not the final value that i want, but i was trying to view if the macro work or not)
I'm missing something?
Thanks for your help!
btw im using Access 2010