-
Hi guys,
How do i detect NULLs in a recordset. forexample:
rst.fields("date").value is actually a null (empty field due to various reasons).
the following simple if else statement cannot do the detection.
if rst.fields("date").value=null then
end sub
else
'carry on with routine
endif
Pls advice.
-
Use the IsNull() function. For example:
Code:
-------------------------------
If IsNull(rst.Fields("Date")) Then Exit Sub
'Or better (if you want to retrieve a nonnull value for the field):
strVal=IIf(IsNull(rst.Fields("Date")),"",rst.Fields("Date"))
-------------------------------
-
Thanks!
Can u explain more on the IIF function?
-
The IIf() function is used to test for a condition. If the condition is true then it returns the first value (in the case of my suggested code, the "") or it returns the second value (in the case of my code, the value in the field rst.Field("Date")). That is to say, the IIf() function in my code tests your field "Date". If the field is null, it returns a "" (to be stored in strVal); if it is not null, it returns the value held in that field.