Trying to get results from a query where the criteria for a memo field is set to "Is Null" and it doesn't work...

Using Access 2016 and the query says it fails.  I tried the function of Cstr([MemoField]) with "Is Null" for the criteria and still no luck.  Any suggestions?
Thanks, Kevin
itsquadSystems AdminAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Fabrice LambertFabrice LambertCommented:
Hi,

Beware that the type convertion function don't accept null value.
Plus manipulating memo fields with strings can lead to unexpected behaviors, such as the result beeing shrunk to 255 characters.

Did you try this ?
[MemoField] IS NULL
0
Jeffrey CoachmanMIS LiasonCommented:
memo field
Do you mean "Long Text"?

Why is cstr() needed?
The query should work well without it...:

SELECT Field1, MemoField
FROM YourTable
Where MemoField IS Null

Am I missing Something?

JeffCoachman
0
Jeffrey CoachmanMIS LiasonCommented:
FWIW,  ...I could only test this in Access 2013.
Another Expert will have to confirm what we posted for Access 2016, ..to be sure...
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Ryan ChongCommented:
have you tried NZ function?

Nz Function
https://support.office.com/en-us/article/Nz-Function-8ef85549-cc9c-438b-860a-7fd9f4c69b6c

but what is actually you want to achieve here?
0
Anders Ebro (Microsoft MVP)Microsoft DeveloperCommented:
Ok, my guess is that your memo field either has "Allow Zero Length" strings set to true, or the field contains either blanks, or non-printable characters.

Cstr will return a STRING variable. This also means that cstr(Null)="" (empty string), however that is still a string, and not the same as null.

I personally for this exact reason always set my string fields to not allow zero length strings.

So I would suggest setting that value to False. If that is not a feasible solution for you, you could try this sql
SELECT Field1, MemoField
 FROM YourTable
 Where MemoField IS Null or MemoField=""

Open in new window


This doesn't solve the issue of strings that contain blanks. Access is smart enough so that if you enter just blanks in a field, access will trim it for you. But if we import data from external sources, sometimes we can get "bad" data into teh database in that way. We could then use the following SQL
SELECT Field1, MemoField
 FROM YourTable
 Where trim(MemoField &"")=""

Open in new window

(Note that the Null case is handled through the string concatenation.

Finally, it happens that we have imported (or copy pasted) a non-printable character. I've only seen it occur maybe a dozen times, and when it does it is usually something I fix manually.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Anders Ebro (Microsoft MVP)Microsoft DeveloperCommented:
Solution posted, no activity from OP
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.