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

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
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,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

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