Unmatched Query returns zero records

thedawn

Registered User.
Local time
Today, 17:10
Joined
Mar 29, 2010
Messages
30
Hi There

I currently use an unmatched query in access that counts the number of records that meet the unmatched criteria. Sometimes this query will return no records.

I need to use the results of this query in a following query that totals two queries together (the one mentioned above and another similar query, They could both return no records so will need to do the same with the other query).

What can I do to get this query to return 0 instead of zero number of records
 
What can I do to get this query to return 0 instead of zero number of records


You could explain what this quote means to you with an example to help readers understand.

Well you could show the SQL for the query(ies) involved.
 
Sorry - it was just an initial question.

The query is as follows and sometimes it will return records but sometimes it will have no records

Code:
SELECT Count([EMPLOYEE DETAILS].[People No]) AS [CountOfPeople No]
FROM [EMPLOYEE DETAILS] LEFT JOIN [People attended allergen] ON [EMPLOYEE DETAILS].[People No] = [People attended allergen].[People No]
WHERE ((([EMPLOYEE DETAILS].[Labour Level]) Not In (xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,xxxxxxxxxxxxxxxxxxxxxxxxxxxx,xxxxxxxxxxxxxxxxxxxxxxxxxx,xxxxxxxxxxxxxxxxxxxxxxx,xxxxxxxxxxxxxxxxxxxxxxx,xxxxxxxxxxxxxxxxxx)))
GROUP BY [People attended allergen].[People No], [EMPLOYEE DETAILS].[Food Manager], [EMPLOYEE DETAILS].[Currently away from business], [EMPLOYEE DETAILS].[Date Left]
HAVING ((([People attended allergen].[People No]) Is Null) AND (([EMPLOYEE DETAILS].[Food Manager])=Yes) AND (([EMPLOYEE DETAILS].[Currently away from business])=No And ([EMPLOYEE DETAILS].[Currently away from business])=No) AND (([EMPLOYEE DETAILS].[Date Left]) Is Null));

The attachment is what shows when there is no records returned by the query and it isn't Null it is no records returned



PQnmFe9QU0o8BDe1ibgmYUeGgPa1PQjAIP7WFtCppR4KE9rE1BMwo8tIe1KWhGgYf2sDYFzSjw0B7WpqAZBR7aw9oUNKPAQ3tYm4JmFHhoD2tT0IwCD+1hbQqaUeChPaxNQTMKPLSHtSloRoGH9rA2Bc0o8NAe1qagGQUe2sPaFDSjwEN7WJuCZhR4aA9rU9CMgt9PQ0jw4Ty0Z5hXfQHNKPDQHtamoBkFHtrD2hQ0o8BDe1ibgmYUeGgPa1PQjAIP7WFtCppR4KE9rE1BMwo8tIe1KWhGgYf2sDYFzSj+BV0iU858xrKKAAAAAElFTkSuQmCCAA==


Thanks
 

Attachments

  • ScreenResult.png
    ScreenResult.png
    4.1 KB · Views: 161
if in the Where Clause, there
is no record returned, then
there is nothing to Count for,
am i correct?
 
Yes that's correct - I have got myself that confused now that I just can't work out what is the way around this
 
Sorry for updating this but I am just wondering if I have asked the question incorrectly - what I want to do if possible is detect whether this query returns zero results even in another query. The reason I ask is that when I try any test on this query I get a blank records. I have tried IsNull, Nz, IsEmpty, IsMissing and am still getting blanks
 
Hi There I have now solved this. I took the count off this query and left it as an unmatched query. I then created another query and left joined to the original EMPLOYEE DETAILS table and used the single output field from the original query as the destination field in the new query and counted this field. This gave me a zero. So I needed an additional step but I am now able to sum any of the queries even ones that return no records
 

Users who are viewing this thread

Back
Top Bottom