Query to return all if null

I have attached a database to return all if the value is null in a count query.
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.

Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
Not sure I understand the question.

 If your basing this on a form control, it's:

 =Forms![myForm]![myFormControl] or Forms![myForm]![myFormControl] Is Null

 When you save the query, Access will re-format that splitting the check of Is Null off on a separate column.

  You can also use Like, but it is not as efficient.

Gustav BrockCIOCommented:
1. You have no count query. If you had, it wouldn't return Null for no records to count, it simply would return no records.

2. Your function EXPORT_IDS makes no sense, as it takes no parameters and always returns Null.

3. Thus, it makes no sense to call InStr(EXPORT_IDS,n) in your query, as it will always fail.
If you called InStr(Nz(EXPORT_IDS),n) it would not fail, but a zero-length string will never contain any other string, thus the returned value will always be 0 (zero).

4. Thus, testing for 0 > 0 will never return records

You can have a query like this that will return a count for an inputted number or the total count if the parameter box for MaxIDS is empty:

SELECT Count(Table1.ID) AS CountOfID
FROM Table1
WHERE Table1.IDS >= Nz([MaxIDS],[IDS]);

Open in new window


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
HuaMin ChenProblem resolverCommented:
select iif(column1 is null,'A',column1) ...

Open in new window

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

From novice to tech pro — start learning today.