Code for IsNull value in a DLookup statement

K

kevin

Hi,

I have some code that looks up the value of a field in a table using the
DLookup function. However if the field has a Null Value the code returns an
error.

Could you tell me what the IsNull code should be?

[Payment Method] = DLookup("[Default Payment Method]", "tblSuppliers",
"[SupplierID]=" & [Supplier] & "")
 
D

Dennis

If you want zero to be returned then try this

[Payment Method] = Nz(DLookup("[Default Payment Method]", "tblSuppliers",
"[SupplierID]=" & [Supplier]),0)
 
G

Gijs Beukenoot

From Dennis :
If you want zero to be returned then try this

[Payment Method] = Nz(DLookup("[Default Payment Method]", "tblSuppliers",
"[SupplierID]=" & [Supplier]),0)

kevin said:
Hi,

I have some code that looks up the value of a field in a table using the
DLookup function. However if the field has a Null Value the code returns an
error.

Could you tell me what the IsNull code should be?

[Payment Method] = DLookup("[Default Payment Method]", "tblSuppliers",
"[SupplierID]=" & [Supplier] & "")

I think Kevin, that he means the [Supplier] field:

[Payment Method] = DLookup("[Default Payment Method]", "tblSuppliers",
"[SupplierID]=" & Nz([Supplier],"") & "")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top