dlook finding NULL

M

Mark

Hi all,

How do I handle this if it is NULL? car_flag_set is Text, it works on
integers if it is null.

vAccumChk = DLookup("[car_flag_set]", "associate_error_summary",
"[associate_id] = txassociate_id")

Thanks!
 
D

Douglas J. Steele

How have you declared vAccumChk?\

If it's declared as Variant, you shouldn't have any problem.

If it's declared as String, wrap the DLookup call in the Nz function.

Incidentally, your DLookup doesn't look correct. I suspect you meant

vAccumChk = Nz(DLookup("[car_flag_set]", _
"associate_error_summary", _
"[associate_id] = " & txassociate_id), "")
 
V

vanderghast

You can use Nz:

vAccumChck= Nz( DLookup( ...), 0 )


where the value in vAccumChck will be 0 if the DLookup was returning a null.
Note that it would be safer to use a variant and to test for NULL, if that
is important:

Dim temp AS variant
temp=DLookup( .. )
if IsNull(temp) then
... ' error? use 0 ?
else
vAccumChck = temp
end if



Vanderghast, Access MVP
 

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

Top