Link to home
Start Free TrialLog in
Avatar of urjudo
urjudoFlag for United States of America

asked on

null or ""

Hi Experts,
I would like to know the difference between null or "" 
for example:  should BDDate = "" or BDDate = null
                         date field or numeric field should use "" or should use Null
                         Text field should use Null not ""
am I correct?

any help would be very appreciated.
Thanks
SOLUTION
Avatar of MouseCaptain
MouseCaptain

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Null means no data exists for a given Field in a Table.
The data is unknown.

"" is a Empty Length String that has not been initialized.

Dim X as String
at this point. X="" ... which IS valid data.

X="Duggan"
Now it's initialized
Avatar of urjudo

ASKER

I tried to do the coding.  
If PDState = "Y" then
   PDUser = ""
end if

when I ran the query if PDUser is not null, one of the case shows in the query, but the PDUser is empty, so I changed to
If PDState = "Y" then
   PDUser = Null
end if
when I ran the same query, the query ran correctly.

that's why I wonder if I should use Null for datefield and text field or I shohld use "" for datefield and Null for text field.
I AVOID Empty Length Strings at all costs as Table Field values  because visually ... you cannot tell a Null from a ELS.

You can use this test

IF Nz(x,"")=""  Then  ' whatever

or

IF Nx(x,"") > "" Then ' whatever
"if I should use Null for datefield and text field or I shohld use "" for datefield and Null for text field."

You should use Null for Both ... then you only have to worry about testing like this .... IsNull (SomeField)
Avatar of urjudo

ASKER

so I should never use "" in coding or I can use "" for if the field is a number field (like 12345)?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of urjudo

ASKER

Thank you!!  I wish I can give you all 500 points each.