First of all, i wrote my access in Chinese, so instead of screenshots ill explain the problem the best i can
---------------------------------------------------------------------------
Table A
Number Ingredient 1 A 2 B 3 C 4 D
TableB
OrderNumber Import OrderPrice 1 A 100 1 B 50 2 A 500 2 C 5 2 D 2000 3 B 40 3 D 1000
(Table A ! [Ingredient]) 1 ~ ∞ (Table B ! [Import] )
Query only include TableA
---------------------------------------------------------------------------------------------------------------------------------
I want to make a Query indicate the latest OrderPrice (which has the largest OrderNumber) of each Ingredient
What i expect:
Number Ingredient LatestPrice 1 A 500 2 B 40 3 C 5 4 D 1000
So far i got it right if each criteria run "independently"
Latestprice: DLookUp("OrderPrice","TableB","OrderNumber=" & DMax("OrderNumber","TableB") & "" ) 'find OrderPrice with largest OrderNumber
Number Ingredient LatestPrice 1 A 1000 2 B 1000 3 C 1000 4 D 1000
Latestprice: DLookUp("OrderPrice","TableB", "[Import]='" & [Ingredient] & "'") 'find OrderPrice with corresponding Ingredient
Number Ingredient LatestPrice 1 A 100 2 B 50 3 C 5 4 D 2000
However, when i combine these as:
Latestprice: DLookUp("OrderPrice","TableB","OrderNumber=" & DMax("OrderNumber","TableB") & "" And "[Import]='" & [Ingredient] & "'")
The 1st criteria (Dmax) seems to overwrite the 2nd criteria
Number Ingredient LatestPrice 1 A 1000 2 B 1000 3 C 1000 4 D 1000
So, where did i did wrong?
Please help me out, and thank you .
---------------------------------------------------------------------------------------------------------------------------
heres the screenshot of my query