Dealing with Null values when using DLookup

ejstefl

Registered User.
Local time
Today, 10:08
Joined
Jan 28, 2002
Messages
378
Hello,

I have two queries that contain a CUISP (similar to a ticker, like for a stock) and the number of holders. My two queries get their data from two different databases. I need a way to add these together. I wrote a function using Dlookup, but I won't always have the same CUSIPS in each table. If I don't, DLookup returns a null value and it won't let me proceed. How can I make this work? Here is the code:

GetNumberOfHolders = (DLookup("CountOfAccount_ID", "qryCount400Accounts", "CUSIP_ID = '" & CUSIP & "'")) + (DLookup("CountOfAccount_ID", "qryCount300Accounts", "CUSIP_ID = '" & CUSIP & "'"))

Can someone suggest a way to do this?

Thanks!
 
You could use «If Not IsNull(DLookUp(...)»
Newman
 
Use the Nz() function with the DLookup.

Here is and example:
Nz(DLookup("CountOfAccount_ID", "qryCount400Accounts", "CUSIP_ID = '" & CUSIP & "'"),0)

HTH
RDH
 

Users who are viewing this thread

Back
Top Bottom