I'm trying to calculate a FIFO auditing analysis of inventory control. This is all done in MS Access 2010.
Unit 1 is added to inventory Today. Unit 2 is added Tomorrow.
Next week when a unit is selected for consumption, ideally we are using Unit 1, but if not, I'm building a query to identify this. So far I've gotten it to work to an extent using a DLookup function.
However, I need to identify which specific older Units were impacted by the failure to do FIFO. That's where DLookup Fails.
Unit # In Date Out Date
A 1/1/13 1/14/13
B 1/1/13 1/14/13
C 1/4/13 1/13/13
D 1/4/13 1/13/13
The above would result in my query spitting out Unit C twice and unit D twice, which is fine. However, each record in the query returns only Unit A when using Dlookup. That's because Dlookup is designed to only find the first value that matches the criteria, not all records.
For example:
Inefficiently Used Unit Overlooked Unit
C A
C A
D A
D A
This is what that DLookup function looks like:
DLookUp("[Container]","Container Efficiency","[Carrier]='" & [Carrier] & "' And [Container Type]='" & [Container Type] & "' And [In Date] < #" & [In Date] & "# And [Out Date] > #" & [Out Date] & "#"))
I need to design it so the criteria produces multiple values.
Inefficiently Used Unit Overlooked Unit
C A
C B
I did research and it appears using Recordsets and VBA would be the way to go. I'm playing with this now (having some trouble replicating the syntax and am considering using FindFirst/FindNext with criteria, then looping), but am getting conflicting opinions on if this is possible or how to go about writing this code.