Selecting all records containing a Null or Empty value in 1 field

  • Thread starter Thread starter Mota
  • Start date Start date
M

Mota

Hello;
I have a Table named MainTBL,having a String field named DOP.
I need a Sql statement that can select all records having DOP=Null or
DOP=Empty.How to write this statement?
Thank you so much.
 
A Text field with nothing in it has the value Null. If the text field's
Allow Zero Length property is set to Yes, the field could also be a zero
length string. A field cannot have the value Empty - that applies only to
Variants in VBA code.

To test for both possible cases:
SELECT * FROM MainTBL WHERE DOP Is Null OR DOP = '';

You almost never need fields in Access/JET to contain zero length strings,
so you can simplify life by setting the Allow Zero Length property to No for
all your text fields.
 
Thank you for your help.

Allen Browne said:
A Text field with nothing in it has the value Null. If the text field's
Allow Zero Length property is set to Yes, the field could also be a zero
length string. A field cannot have the value Empty - that applies only to
Variants in VBA code.

To test for both possible cases:
SELECT * FROM MainTBL WHERE DOP Is Null OR DOP = '';

You almost never need fields in Access/JET to contain zero length strings,
so you can simplify life by setting the Allow Zero Length property to No for
all your text fields.
 
Back
Top