[thelist] Testing for the various NULL's

Joel Canfield joel at spinhead.com
Thu Dec 5 10:53:01 CST 2002


--
[ Picked text/plain from multipart/alternative ]
> Unfortunately, this works while the cell is "<NULL>" but not
> when the cell is left blank. I've tried these other tests and
> still no success to skip this line of output:
>
> if manager.fields.item("Address2").value <> "" then
> if not manager.fields.item("Address2").value = "" then
> if manager.fields.item("Address2").value <> NULL then
> if not manager.fields.item("Address2").value = NULL then
> I've tried the isNULL keyword but ASP doesn't like it.
>
> For some odd reason, a blank cell behaves quite differently
> than a "<NULL>" cell.

Right; an empty text string is very different from 'no value at all', which
is what NULL means.

If it's possible to have either NULL or an empty string, check for both. To
be really thorough, you can check for
if not IsNull(manager.fields.item("Address2").value) and
not IsEmpty(manager.fields.item("Address2").value) and
not (manager.fields.item("Address2").value) = "" then
whatever

I won't swear you can copy and paste this code; I'm just illustrating that
you can have multiple cases where you don't have a value in the field, and
they all behave slightly differently.

> p.s. Even odder still, I've got two identical pieces of code (copy and
> pasted) that exert the same behavior. One works to skip the code, the
other doesn't.
> Like I said, these pieces of code are identical...

Invisible elves. In the one that's not working, delete it and retype it
manually. Duplicate verbatim the working model, but don't copy and paste. I
know it sounds goofy, but I've had it resolve ghost problems more than once.
Invisible control characters sometimes slip in (you're working on a Windows
machine, right?) and they move when you copy/paste, but retyping clears it
up.

joel



More information about the thelist mailing list