dlook finding NULL

  • Thread starter Thread starter Mark
  • Start date Start date
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!
 
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), "")
 
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
 
Back
Top