Bizarre VARIANT behavior

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
 
D

Douglas J. Steele

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
 
D

Dennis

THANK YOU! That did it!!

Dennis

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

;^)
 

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