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"),"")
 
Back
Top