casey
12-20-2000, 09:01 AM
Can I use 2 criteria with the DLookup function?
Ex:
DLookup("[Quantity]", "Sale Details", "[ComputerID] =" & [Forms]![ComputerParts]![List7]
And "[PartID]=" & [Forms]![ComputerParts]![List9])
If so, does anyone know the correct way to do this?
I get a "type mismatch" error.
Jack Cowley
12-20-2000, 09:28 AM
Try:
DLookup("[Quantity]", "Sales Details", "[ComputerID]= " & Me![List7] & " & " And[PartID] = " & Me![List9] & ")
I hope I got this right.....
Talismanic
12-20-2000, 09:43 AM
casey what is your criteria? Is it static or does it change. I don't know of a way to do it with a macro but it can probably be done with a IF Then Statement like this:
If [Field1] = Criteria1 and [Field2] = Criteria2 then
DLookup
End IF
Post back with more details.
EditOoops Jack and were posting at the same time and he beat me to the Submit button. Let us know if that worked or not./Edit
[This message has been edited by Talismanic (edited 12-20-2000).]
casey
12-20-2000, 04:36 PM
Thanks for your advice. Apparently, I needed the DCount function instead of DLookup. The following syntax is correct for concatenating 2 criteria in the function:
DCount("[Quantity]", "SaleDetails", "[ComputerID] = " & [Forms]![ComputerParts]![List7]& "AND [PartID] = " & [Forms]![ComputerParts]![List9]&)
The only difference being that the AND is included in the quotation marks("").
Thanks again for your help.