Results 1 to 2 of 2
  1. #1
    dhicks19 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Apr 2012
    Posts
    17

    Count query return zero instead of null/blank

    Hi, first off I am totally new to access and vba.



    I basically have a report fed from a count query. Heres my sql code for the query

    SELECT TblDailyChecksArchive.Machine, TblDailyChecksArchive.CheckID, TblDailyChecksArchive.CheckName, TblDailyChecksArchive.MaxDay, TblDailyChecksArchive.Identifier, TblDailyChecksArchive.Complete, TblDailyChecksArchive.Reason, TblDailyChecksArchive.Department, TblDailyChecksArchive.Chkdate, TblDailyChecksArchive.Result, TblDailyChecksArchive.operator, TblDailyChecksArchive.LowerLimit, TblDailyChecksArchive.UpperLimit, TblDailyChecksArchive.NotRunning, TblDailyChecksArchive.Nights, TblDailyChecksArchive.carryover
    FROM TblDailyChecksArchive
    WHERE (((TblDailyChecksArchive.Chkdate)=IIf(Weekday(Date ())=2,Date()-3,Date()-1)));


    I have uploaded pics of the returned result from query and the report I am wanting to use.

    My problem is basically, we have a table that stores checks that need to be carried out daily. It stores whether they are complete or incomplete (-1) is completed and (0) is not complete.
    I am trying to use a report that counts the checks, sees how many are complete and incomplete, then works out the percentage of completed check over the total amount of checks for that particular area ( cell 1,2,3,4).

    E.g - If for instance cell1 has 164 checks in total, and 164 checks were complete, on the report it would show the 164 checks as completed but will not show incompleted checks as 0, because the query returns null and not a 0.

    I need it to show 0 so I can work out the percentage properly.

    Sorry, its hard to explain what the problem is. Any help would be appreciated.




    Click image for larger version. 

Name:	query.PNG 
Views:	16 
Size:	12.4 KB 
ID:	7259

    Click image for larger version. 

Name:	report.PNG 
Views:	16 
Size:	25.0 KB 
ID:	7260

  2. #2
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    There is a Function called the 'Nz' function that you can use in your query [or in VBA] that you can 'tell' to return a 0 instead of a Null.
    For instance - in Query Design, you could create a field named 'IncompleteChecks' - like this:
    Code:
    IncompleteChecks: Nz([IncompleteChecks],0)
    I hope this helps. Let us know if you need more help.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. count blank colums in crosstab query
    By survivo01 in forum Queries
    Replies: 6
    Last Post: 04-13-2012, 01:37 PM
  2. Replies: 9
    Last Post: 03-09-2012, 02:55 PM
  3. Query return 0 for null values
    By rachello89 in forum Access
    Replies: 4
    Last Post: 02-23-2012, 08:38 AM
  4. Blank form on null query results
    By JackieEVSC in forum Forms
    Replies: 11
    Last Post: 11-30-2011, 08:39 AM
  5. use 0 for null value in count query
    By hyperionfall in forum Queries
    Replies: 1
    Last Post: 11-07-2010, 05:12 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums