Access 2010
Access 2003
Seminars
Tips & Tricks
Access Forum
Course Index Insider Circle
 
Tutorials   News   Tips   Forums   Help   Logon   Order  
 
     
 
Tips & Tricks

New Tips Added Weekly!
Click here to get on our Mailing List

   

  Access   Excel   Word   Windows   FrontPage   Hardware   Misc

 

NULL v. Zero Length String

What's the difference between a NULL value and a Zero Length String

Q: What is the difference between a NULL value and a Zero Length String?

A: The difference between a NULL and a Zero-Length String (ZLS) is that a NULL has no value, whereas a ZLS has been specifically given a value of blank. It's basically the difference between saying, "no value" or "no value YET."

Furthermore, this distinction usually only comes about in Access when you're dealing with VBA programming and you either set the ZLS value yourself, or return the value as part of a function call, such as:

   LastName = ""
   FirstName = NULL


When you're entering data in a table or form, you will usually either specify some data, or no data. Your fields will either have a value, or they will be NULL. Even if you type in a value and then come back later and delete it, it will still be NULL. Manually deleting data from a table sets it to NULL, so the average user will never really have to worry about what a ZLS is.

However, let's say you're creating a database where you need to know more specific information on people. Let's say you're tracking first, middle, and last names, and you NEED to know whether or not someone has a middle name. You could set their middle name equal to a ZLS to indicate that they have NO middle name, as opposed to not knowing what their middle name is. Statistically it could make a difference. You could make a button, for example, that just says:

    MiddleName=""

You can check for ZLS by looking for "" - an empty string. You can check for NULL by using the IsNull function. In your VBA code this will often result in looking for both:

    If IsNull(LastName) or LastName="" Then
        ' Do some stuff
    End if


You can prevent ZLS in your table by changing the Allow Zero Length property of a text or memo field to No/False. This will prevent any ZLS values from getting in your table.

Do you need to worry about any of this? For the most part, no. The difference between NULL and ZLS is mostly theoretical, and unless you're specifically coding your database to CARE about the difference between the two, you shouldn't have to worry about it. However, because some functions might return a ZLS, you might want to check for both in your VBA comparisons. Usually this distinction only matters when you need to care about the difference between NO value and no value YET.

Also, Access will index NULL values and ZLS values differently, which is a whole different topic of discussion.

 

 

You may want to read these articles from the 599CD News:

 

 
Learn
 
Microsoft Access
Microsoft Excel
Microsoft Word
Microsoft Windows
Microsoft PowerPoint
Adobe Photoshop
Visual Basic
Active Server Pages
Online Seminars
More...
Customers
 
Account Login
Online Theater
Downloads
Lost Password
WalkThru Tutorials
Free Upgrades
Insider Circle
Info
 
Latest News
New Releases
User Forums
Tips & Tricks
Search Our Site
Waiting List
Production Schedule
Help
 
Live Chat
Customer Support
Troubleshooting
FAQs
TechHelp
Consulting Services
About Us
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Order
 
Video Tutorials
Handbooks
MYOLP Memberships
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Live Chat
General Contact Info
Support Policy
Contact Form
Email Us
Mailing Address
Phone Number
Fax Number
Course Survey
Try Us
 
Free Lessons
Online Theater
Mailing List
Course Indexes:   Microsoft Access   Microsoft Excel   Microsoft Word   Microsoft PowerPoint   Visual Basic (VB)   Photoshop   Active Server Pages (ASP)  
Keyword Search Cloud:   What's This?   courses   microsoft access tutorials   vlookup   access   cartesian   excel   dlookup   vba   attendance   access 2007   sql   windows 7   combo box   pivot table   visual basic   test   iif   word   calendar   query   conditional formatting   pivot tables   photoshop   hlookup   access 101   excel 202   excel 2007   student attendance   update query   my account   word 2007   append query   quickbooks   queries   dsum   reports   powerpoint   if   microsoft access   dmax   mail merge   relationships   ms access   access 2010   vb   dcount   subforms   excel 2003   handbooks   html   599cd   combobox   if function   security   microsoft word   after update  
Copyright 2012 by 599CD.com, All Rights Reserved