Dlookup is giving an #error (1 Viewer)

aron.ridgway

Registered User.
Local time
Today, 12:52
Joined
Apr 1, 2014
Messages
148
Hi there i am trying to do a Dlookup in an textbox which is looking at a query that isnt a bound source of the form. my code is
Code:
 =DLookUp("[EmailAddress]","[qrySupplierEmail]","[SupplierPK]=" & [Forms]![frmPurchaseEntry]![SupplierFK])
Im looking for the field Emailaddress in the query, matching the supplier Primary key to the Form Supplier Foreign key.

Email address is hyperlink, the PK and fk are short text. I've used a simular Dlookup before but having no luck with this one?

Am i doing anything obviously wrong?

thanks
 

JHB

Have been here a while
Local time
Today, 13:52
Joined
Jun 17, 2012
Messages
7,732
If [SupplierPK] is a text field type, then you are missing two '
=DLookUp("[EmailAddress]","[qrySupplierEmail]","[SupplierPK]='" & [Forms]![frmPurchaseEntry]![SupplierFK] & "'")
 

bob fitz

AWF VIP
Local time
Today, 12:52
Joined
May 23, 2011
Messages
4,722
Perhaps that needs to be something like:
=DLookUp("[EmailAddress]","[qrySupplierEmail]","[SupplierPK]='" & [Forms]![frmPurchaseEntry]![SupplierFK])[/CODE] & "'")
 

aron.ridgway

Registered User.
Local time
Today, 12:52
Joined
Apr 1, 2014
Messages
148
thank you for the reply, I have tried the following
Code:
 =DLookUp("[EmailAddress]","[qrySupplierEmail]","[SupplierPK]='" & [Forms]![frmPurchaseEntry]![SupplierFK] & "'")

with the same result?

The error# flashes in the textbox?
 

aron.ridgway

Registered User.
Local time
Today, 12:52
Joined
Apr 1, 2014
Messages
148
I moved the ' further along and it is now working

Code:
 =DLookUp("[EmailAddress]","[qrySupplierEmail]","'[SupplierPK]=" & [Forms]![frmPurchaseEntry]![SupplierFK] & "'")

thanks for pointing me in the right direction!
 

bob fitz

AWF VIP
Local time
Today, 12:52
Joined
May 23, 2011
Messages
4,722
Glad you have it working but a bit surprised by the solution you posted. I'm sure the usual syntax would be as posted by myself and JHB. I would like to hear from anyone who can explain why it is different in this case.
 

JHB

Have been here a while
Local time
Today, 13:52
Joined
Jun 17, 2012
Messages
7,732
I moved the ' further along and it is now working

Code:
 =DLookUp("[EmailAddress]","[qrySupplierEmail]","'[SupplierPK]=" & [Forms]![frmPurchaseEntry]![SupplierFK] & "'")
thanks for pointing me in the right direction!
It should NOW give an error so as bob fitz I'm really surprised, could we get an small copy of your database, with some sample data, so that we could investigate why it work by your code?
 

Users who are viewing this thread

Top Bottom