My setup:
Tables: Products, PurchaseDetails
I have a PurchaseOrder form which allows me to select products and add them to the purchaseDetails table. I would like to be able to view the average purchase price when adding them however I am not sure how to do this
My PurchaseOrder form is a multiple items form so I can add multiple products. When I try to add a query to display the average price paid it averages all the products prices, not the prices for each product paid previously
Example:
1/1/13 purchase
Apple Price Paid today: $1
Orange $1.5
1/2/13
Apple $2
Orange $2
what I'd like to do is:
New purchase
Apple avgPrice:1.50 Price Paid today: $1
Then next time the avgPrice would be (1+1.5+1)/3
I've tried to add a query to the form, but it shows the average price for the orange and apple
I was thinking I could add a calculated field in the product table based on the query of avgPrice paid for that ProductID, not sure if that is possible
If not perhaps I could do an afterUpdate Event on the purchase Table, I would want to run a query and set that result in the product table. I don't know how to run a query from there though, I am using macro tools, I don't really understand VBA so I'd rather steer away from that incase I need to tweek it in the future
Thanks for any help




