isnull and ""

S

Steven Scaife

I have a quick question i tried searching google but couldn't find anything

What is the difference between not isnull(val) and <> ""

can this statement be reduced from

If NumberDep <> "" or not isnull(NumberDep) then HBinsertSQL = ",
NoOfDependants = " & NumberDep

to

If not isnull(NumberDep) then HBinsertSQL = ", NoOfDependants = " &
NumberDep

I would like to know what the difference is and if possible any links that
have a good description

thanks in advance
 
J

John

There are several articles on the net. IsNull in Jet is other than in Sql
etc...
If you want to avoid IsNull, then fill in the Default value of the fields as
"", otherwise it will be NULL and you have to check on IsNull and "".
 
B

Bob Barrows [MVP]

Steven said:
I have a quick question i tried searching google but couldn't find
anything

What is the difference between not isnull(val) and <> ""

Null means that the content of val is unknown.
"" means that the content of val is ""

See the difference? With null, we don't know what it contains. With "", we
know what it contains.
This has a little more information:
http://blogs.msdn.com/ericlippert/archive/2003/09/30/53120.aspx
followed by http://blogs.msdn.com/ericlippert/archive/2003/10/01/53128.aspx
can this statement be reduced from

If NumberDep <> "" or not isnull(NumberDep) then HBinsertSQL = ",
NoOfDependants = " & NumberDep

to

If not isnull(NumberDep) then HBinsertSQL = ", NoOfDependants = " &
NumberDep

I like to use
If len(NumberDep) > 0 then

Since the length of null is null, it will never be greater than zero. And
since the length of "" is zero, this case will also be handled.

I only use IsNull if different actions need to be taken depending on
whether the test value is null or if it contains ""

Bob Barriws
 

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

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top