Dlookup

  • Thread starter Thread starter Sandy R.
  • Start date Start date
S

Sandy R.

I receive an "Invalid use of null" error when I use the
Dlookup function and the field in the table is empty. How
can I get past this error? How would I write an If
Statement to check for null?
Thanks
 
Generally, if the dlookup fails...it returns a null...and should not give
you such an error message.

It is not clear what context you are using dlookup.

if it is in code to assign something..you can use:


dim vMyVAr

vMyVar = dlookup("theField","theTable","id = 123")

if isnull(vMyVar) = True then
msgbox "result is null"
else
you code here...
end if

If you want to lookup to return a zero value you can use the nz command. The
nz command will converta null value to whatever

So:

= nz(dlookup("theField","theTable","id = 123"),0)

The above will return 0 for all cases that fail. This is handly if you are
going to sum the results.

You can also reutnr a zero length string like:

= nz(dlookup("theField","theTable","id = 123"),"")
 

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

DLookup and Nz 0
DLookUp - Null 4
Access ACCESS DLOOKUP INVALID USE OF NULL 0
#Error from dlookup 2
dlookup with if 1
Problem with Dlookup with 2 criteria 1
Dlookup error 4
DLookup returns NULL incorrectly. 3

Back
Top