Solved

How to add NULLs to an Access Database

Posted on 2011-03-11
10
254 Views
Last Modified: 2012-06-27
Hello,

I have an Access database with some forms with a variety of controls for a variety of data types on it:  Text boxes for alpha characters, numeric data types, date fields, drop down list boxes, and check boxes.

To show that data is unknown, not applicable, or that the data will be added later, I like to insert a NULL. How can I do this with Access 2007?

Thanks,
0
Comment
Question by:gtrapp
10 Comments
 
LVL 19

Expert Comment

by:MINDSUPERB
ID: 35114458
Gtrapp,

At the time you insert a record in a table and even entering only one value of its fields, other fields are defaulted to be nulled.

Let us say you have ID, FirstName, LastName, DOB in your table. When you enter even only the FirstName for that record, ID, LastName and DOB are already null.

Sincerely,
Ed
0
 
LVL 75
ID: 35114497
"like to insert a NULL. "
Are you talking about *existing* records or new records ?

mx
0
 
LVL 84

Assisted Solution

by:Scott McDaniel (Microsoft Access MVP - EE MVE )
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 166 total points
ID: 35115597
As suggested by mx:

If you're dealing with existing records, you can update a column to a Null value like this:

"UPDATE MyTable SET Col1= NULL"

Note also that 2007 changed the way tables fields are added (during design) to NOT include some defaults - for example, in 2003 and earlier a Numeric field was ALWAYS defaulted to 0. That changed in 2007 - there is no Default value unless you set one.
0
 
LVL 75
ID: 35117298
". That changed in 2007 - there is no Default value unless you set one."
It's about time !

Another way at the Form level to add Nulls to Fields in Existing records is using the Form Before Update event, which might end up looking like this:

Private Sub Form_BeforeUpdate (Cancel As Integer)
    Me![Field1] = Null
     Me![YourFieldName] = Null    

End Sub
0
 

Author Comment

by:gtrapp
ID: 35131327
I am talking about new records, and adding records via a form or the datasheet. I looking for like a 3 state for fields. Some lIke:

1. Blank or nothing
2. Actual values (numbers or characters or a date)
3. NULL

How can I do this for numeric, checkbox, date or text columns)?
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 75
ID: 35131355
Blank or Nothing is the same as Null in Access.

mx
0
 

Author Comment

by:gtrapp
ID: 35132760
So, if blank or nothing is the same as NULL in Access, how to avoid putting UNKNW in numeric fields in Access? I could change all of my date and numeric fields to Text, I suppose. Any suggestions?
0
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Access MVP) earned 334 total points
ID: 35132814
If you define a Field in a Table as Numeric, then the Field size as whatever ... Long, Single, etc ... those fields will in fact be Null until some valid numeric value is entered ... either directly at the table lever or at the form level.

"I could change all of my date and numeric fields to Text, I suppose."
Probably not a good idea.

I'm not really sure what your concern is here ... ?

mx
0
 

Author Comment

by:gtrapp
ID: 35132972
Well, more on the lines of convincing the user that a blank field or field with nothing in it represents UNKNOWN.
0
 
LVL 75

Assisted Solution

by:DatabaseMX (Joe Anderson - Access MVP)
DatabaseMX (Joe Anderson - Access MVP) earned 334 total points
ID: 35133064
Well it does ... that's just a fact in Access.  If they choose not to accept that, it should not have to be your problem.  

mx
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now