Dlook for text with 2 criteria (1 Viewer)

theinviter

Registered User.
Local time
Yesterday, 20:37
Joined
Aug 14, 2014
Messages
240
HI guys ,
need help please,
i am designing a query for report and i am having field name drug name in query, where the user can enter drug name in the form so what i want is that;
to dlookup for the drug selected by user in Drug list (Table) to match the selected drug with 1- Drug name (text) and 2- chemo_drug (yes/No) and display only drug that match 2 criteria.

i tried this code

DLookUp("[drug name]","[drug list]","[drug name] ='" & [Drug name] & " AND [Chemo_drug]= " & "0" & "'")

but sow no record.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 20:37
Joined
Oct 29, 2018
Messages
21,449
Hi. What do you get with this?
Code:
 DLookUp("[drug name]","[drug list]","[drug name] ='" & [Drug name] & "' AND [Chemo_drug]=0 ")
 

isladogs

MVP / VIP
Local time
Today, 04:37
Joined
Jan 14, 2017
Messages
18,209
Try this
Code:
DLookUp("[drug name]","[drug list]","[drug name] ='" & [Drug name] & "' AND [Chemo_drug]= 0")

However using DLookup in a query will be slow. There may be better ways.
Can you post the SQL for your query
 

Gasman

Enthusiastic Amateur
Local time
Today, 04:37
Joined
Sep 21, 2011
Messages
14,221
I would ask, why are you looking up drug name when you are supplying drug name? :confused:
 

theinviter

Registered User.
Local time
Yesterday, 20:37
Joined
Aug 14, 2014
Messages
240
because i need to filter report based on selected drug.
 

plog

Banishment Pending
Local time
Yesterday, 22:37
Joined
May 11, 2011
Messages
11,638
because i need to filter report based on selected drug.

Whoosh.

If you need to do that, why not just use the selected drug name to do so? What does the Dlookup do?
 

theinviter

Registered User.
Local time
Yesterday, 20:37
Joined
Aug 14, 2014
Messages
240
because i have 2 report each will show data based on check mark (YES/NO) option
 

Users who are viewing this thread

Top Bottom