null values

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!!
 
G

Guest

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
 
G

Guest

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.
 

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