null values

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am opening an ADODB recordset rs. If fld is the ADODB.Field, I check to see
if fld is null or not with:

For Each fld in rs.Fields
If fld.Value = Null Then
'do something
Else
'do something else
End If

It always goes to the ELSE statement, whether or not the original value in
the table is null. What am I missing?
Thanks!!
 
NULL is not equal to anything, not even itself.

If NULL = NULL Then
MsgBox "TRUE"
Else
MsgBox "False"
End If

will *always* result in the message "False". I haven't used an ADODB
recordset, but in a DAO recordset, to test for NULL, you have to use the
IsNull() function

Try using

For Each fld in rs.Fields
If IsNull(fld.Value) Then
'do something
Else
'do something else
End If

HTH
 
thank you so much! That resolved it and I had been fighting with this for
weeks. It seems so simple, I wonder that I didn't think of that.
 
Back
Top