I'm trying to ascertain the best way to test for blank/empty/null text records.
By this I mean text records which are either:
- Null
- An Empty String (
""
) - Any number of spaces (e.g.
" "
)
I've experimented with varying query criteria using the following table (named Table1
):
Here, the Spaces
record contains an arbitrary number number of spaces, the Empty String
record contains an empty string (""
), and the Null
record is just that.
My first thought to achieve my goal was to use a query such as:
SELECT * FROM Table1 WHERE TextField IS NULL OR Trim(TextField)=""
And this indeed returns the three target records: Spaces
, Empty String
& Null
.
However somewhat oddly, using:
SELECT * FROM Table1 WHERE TextField = ""
Returns both the Empty String
record and the Spaces
record:
Which leads me to think that my query can omit the Trim
function and become:
SELECT * FROM Table1 WHERE TextField IS NULL OR TextField=""
- But is this reliable?
- Is this best practice when selecting empty text records?
Alternatively I considered using:
SELECT * FROM Table1 WHERE Nz(TextField)=""
- Are there drawbacks to this approach?
- Are there better ways to achieve this?
EDIT: To be specific, my question is ultimately:
What is the best way to select blank text records?
WHERE TextField & "" = ""
– ZoieTrim(TextField) & "" = ""
– Zoie