|
Question : DLookup with multiple criteria
|
|
Experts,
I am having a problem contructing a DLookup function in a query that looks for a value in a table.
Table: tblProduction Field Name1: ProductName (numeric) Field Name2: Year (numeric) Field Name3: OpQty (numeric)
Query Name: qryInventoryInsAndOuts Query Field1: ProductName (numeric) Query Field2: Year (numeric)
OpQty is actually ending inventory which would also be beginning inventory for the next year. I want to be able to show beginning inventory in the query using a DLookup function.
What I want to do: Beginning Inv: Lookup OpQty in tblProduction where ProductName in the table = ProductName in the query AND Year in the table = Year MINUS 1 in the query.
This function does not work, but should be pretty close: Beginning Inv: DLookUp("[OPQty]","tblProduction","[Year] = [Year] and [ProductName]=[ProductName]")
Thanks, Dale
|
|
Answer : DLookup with multiple criteria
|
|
try this
SELECT ProductName, [Year], DLookUp("[OPQty]","tblProduction","[Year] = " & [Year]-1 & " AND [ProductName] =" & [ProductName]) AS [Beginning Inv] FROM tblProduction
|
|
|
|