Bizarre VARIANT behavior

  • Thread starter Thread starter Dennis
  • Start date Start date
D

Dennis

I have a DLookup statement which returns a value or NULL
(as you know), depending upon whether or not a record was
found. I've defined the var as a VARIANT, but the
associated IF statement isn't working.

If NOT varX Then
..
..
Else
..
..
End If

It's always going to the ELSE, no matter what the value of
varX is. The Watch window shows "Null", but the IF doesn't
care. I've changed it back and forthe between positive
checking and NOT, to no avail. I've stried defining varX
as a string, but I get an "Illegal use of Null" error at
the DLookup. I'm out of ideas. Any thoughts?

Thanks a million!

Dennis
 
NOT is for binary values, not to determine whether or not a variant is Null.

Try:

If IsNull(varX) Then
' no value found for varX
 
THANK YOU! That did it!!

Dennis

PS: I'm an old COBOLer so that should explain why I tried
to use NOT (lol)....

;^)
 
Back
Top