Query to return 0 is no record is found

tmyers

Well-known member
Local time
Today, 05:19
Joined
Sep 8, 2020
Messages
1,091
I am trying to make a query that returns 0 if no record is found which would mean all conditions are met and the base query would not return anything but I am getting a syntax error.
SQL:
SELECT ISNULL(
SELECT tblMultiConductorCut.TicketID, tblMultiConductorCut.MultiComplete
FROM tblMultiConductorCut
WHERE (((tblMultiConductorCut.TicketID)=[Forms]![frmWireRoom]![TicketID]) AND ((tblMultiConductorCut.MultiComplete)=False)),0);
 
Use DCount() ?

Are you confusing IsNull with NZ() ?
 
I thought about DCount but after reading various post from Stack Overflow and such, most people seem to suggest ISNULL over DCount for some reason. Ill give DCount a try.
 
Care to post the links?
 
Completely missed that is was TSQL. I have also been working in SQL Server so completely missed the fact that it was not a function in Access.
 
Every SELECT needs a FROM. I count 2 SELECTS, 1 FROM.

I am trying to make a query that returns 0 if no record is found

That's one condition, now what is suppose to happen when not 0 records ae found? What do you expect the query to return when there are results?

My gut is telling me that you've gone down a bad path for your ultimate goal and seeking help for that bad path. You are asking for help with an issue that isn't part of the best solution for the big picture. So, what is the big picture? What are you ultimately trying to do? This is an intermediate step--what do you plan on doing with that 0?
 
The ultimate plan is to use this step to verify all records are flagged as complete, which if they are, the query would not return anything since everything WOULD be complete. I would then allow a process to finish and close out an order.
 
That made very little sense. How's this---you build this query that returns 0 records. What would the next step be?
 
The ultimate plan is to use this step to verify all records are flagged as complete, which if they are, the query would not return anything since everything WOULD be complete. I would then allow a process to finish and close out an order.
Sounds ideal for a DCount ?
 
I have also been working in SQL Server so completely missed the fact that it was not a function in Access.
Just FYI, IsNull() is definitely a function in Access. It just does a different job than the one in T-SQL.
 

Users who are viewing this thread

Back
Top Bottom