Dual Criteria for DLookup

TB11

Member
Local time
Today, 00:10
Joined
Jul 7, 2020
Messages
84
Hi.

I'm trying to do a dual criteria, but I either get errors or the wrong person for the DLookup.

This part works fine: Expr1: DLookUp("[PersonFullName]","Person","[IDPerson]=" & [fkPerson])

When I try to add in the second criteria, that the fkRole =2 is where I'm stuck. (The fkRole is already part of the query.) The fields in the query are: fkPerson, fkRole, Expr1,
Exp2 for the results that I am struggling with.

Any thoughts?

Thanks.
 
Have you tried something like?
Code:
DLookUp("[PersonFullName]","Person","fkRole=2 AND [IDPerson]=" & [fkPerson])
 
TheDBGuy was faster on the draw...
As above ... but for info you don't need the square brackets as your field names have no spaces or special characters

Code:
DLookUp("PersonFullName","Person","fkRole=2 AND IDPerson=" & fkPerson)
 
Code:
Expr1: DLookUp("[PersonFullName]","Person","[IDPerson]=" & [fkPerson])

DLookups have no place in a query.

When you are building a query and need data from a source (query or table) you bring that source into the query and link appropriately. If you need to apply criteria to it you do so inside the query as well.
 
@Pat Hartman You rock. You are right. No records satisfied both criteria. You got me thinking on the right track. This is how I got it to work.

Expr1: IIf([fkPerson]=2, DLookUp("[PersonFullName]","Person","[IDPerson]=" & [fkPerson]))

THANK YOU!
 
@Pat Hartman You rock. You are right. No records satisfied both criteria. You got me thinking on the right track. This is how I got it to work.

Expr1: IIf([fkPerson]=2, DLookUp("[PersonFullName]","Person","[IDPerson]=" & [fkPerson]))

THANK YOU!
Hi. Glad to hear you got it sorted out. Good luck with your project.
 

Users who are viewing this thread

Back
Top Bottom