Type Mismatch in DLookup with multiple criteria

adibakale

Board Regular
Joined
Apr 10, 2015
Messages
52
I am receiving a Type Mismatch error and cannot figure out why. I had a Dlookup with 1 criteria, which was working fine. I have been trying to 2 additional criteria which come from the same table to this dlookup, however I keep getting a type mismatch error.
Here is my code:

M_ID = DLookup("Id", "tbl_Merchant", "[MERCHANT NAME] = '" & mer & "'" And "[MERCHANT city] = '" & mer_city & "'" And "[MERCHANT COUNTRY] = '" & mer_country & "'")

Any help with this is greatly appreciated.
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Try M_ID = DLookup("Id", "tbl_Merchant", "[MERCHANT NAME] = '" & mer & "' And [MERCHANT city] = '" & mer_city & "' And [MERCHANT COUNTRY] = '" & mer_country & "'")

It looks like your And operators are not enclosed in quotes. This "'" ends the string part that is enclosed, then you follow it with And, which is not enclosed.
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top