I am opening query as recordset and looping through the records, doing calculation with the some of the data and appending the record to another table. These are the product quantity, cost, sales price and profit margin records for half month say 1/1 through 1/15.
Generally, there is only one record for each product type but sometime due to salesprice change there can be two records for one product. How can I set up the inner loop so that it will loop within the outer loop and do the calculation until the product ID is same and exit the inner loop when product ID changes.
Sample Data for the query
ProductID Qty Cost SalesPrice TotSalesPrice
A 5 10 12 60
A 8 10 13 104
B 10 12 15 150
B 10 12 14 140
I cannot total by product ID in the query as I need to append the last salesprice in another table.
There are much more fields but have shown the fields I need for inner loop.
Thanks for your time and help
Generally, there is only one record for each product type but sometime due to salesprice change there can be two records for one product. How can I set up the inner loop so that it will loop within the outer loop and do the calculation until the product ID is same and exit the inner loop when product ID changes.
Sample Data for the query
ProductID Qty Cost SalesPrice TotSalesPrice
A 5 10 12 60
A 8 10 13 104
B 10 12 15 150
B 10 12 14 140
I cannot total by product ID in the query as I need to append the last salesprice in another table.
There are much more fields but have shown the fields I need for inner loop.
Thanks for your time and help