MasterRacker
New member
I have a data set like the following:
[tt]TransactionID TransactionDate ProductID UnitsReceived UnitPrice
200 08/30/09 123 10 10.00
175 07/15/09 123 5 7.50
140 07/05/09 123 11 9.00
[/tt]
If I have 12 units on hand, the stock value calculation would be 10@10.00 + 2@7.50. If I had 17 units on hand, the value would be 10@10.00 + 5@7.50 + 2@9.00. It's alwas the most recent shipments whose prices are used since the older prices are used elsewhere in disbursement calculations.
I'm think I'm going to load a recordset sorted in descending date order and just use MoveNexts to iterate through it to do the calculations.
I did have another idea however to use dlookup and the MAX date and then if I needed more units, to do another dlookup based on MAX date less than the date I just used.
Just out of curiosity, would 2 or 3 dlookups execute faster or slower than loading a full recordset that may have a years worth of receipts? (Which may not be that many - this is more of a theoretical question.)
Jeff
[small][purple]It's never too early to begin preparing for [/purple]International Talk Like a Pirate Day
"The software I buy sucks, The software I write sucks. It's time to give up and have a beer..." - Me[/small]
[tt]TransactionID TransactionDate ProductID UnitsReceived UnitPrice
200 08/30/09 123 10 10.00
175 07/15/09 123 5 7.50
140 07/05/09 123 11 9.00
[/tt]
If I have 12 units on hand, the stock value calculation would be 10@10.00 + 2@7.50. If I had 17 units on hand, the value would be 10@10.00 + 5@7.50 + 2@9.00. It's alwas the most recent shipments whose prices are used since the older prices are used elsewhere in disbursement calculations.
I'm think I'm going to load a recordset sorted in descending date order and just use MoveNexts to iterate through it to do the calculations.
I did have another idea however to use dlookup and the MAX date and then if I needed more units, to do another dlookup based on MAX date less than the date I just used.
Just out of curiosity, would 2 or 3 dlookups execute faster or slower than loading a full recordset that may have a years worth of receipts? (Which may not be that many - this is more of a theoretical question.)
Jeff
[small][purple]It's never too early to begin preparing for [/purple]International Talk Like a Pirate Day
"The software I buy sucks, The software I write sucks. It's time to give up and have a beer..." - Me[/small]