Results 1 to 3 of 3
  1. #1
    JustAnElf is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Oct 2013
    Posts
    16

    Yes/No Data type and the Null value in queries.

    Greetings one and all,



    This is driving me NUTS. All I'm trying to do is count how many times the Yes/No field has been set to Yes in all of the records. My query works great until all of the records have the field set to NULL. At that point the query returns no value. How do I make it return a 0? I've been trying to use the Nz function with little success. For help I've included a picture of what my query looks like. The field ScriptIsComplete is the Yes/No field. Does anyone have any suggestions?

    Click image for larger version. 

Name:	YesNoField.jpg 
Views:	7 
Size:	24.9 KB 
ID:	14435

  2. #2
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Can you show what tables you have involved?



    You only require one field to count the field

    scriptiscomplete
    tblKnowledgeScripts
    Count
    true

    for any null use

    nz()

    so nz(fieldthatisnull,0)

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Try:

    SELECT Sum(IIf(ScriptIsComplete=Yes,1,0)) As CountYes FROM tablename;
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 8
    Last Post: 08-17-2023, 02:33 AM
  2. type error if sub report has null vallue
    By tagteam in forum Access
    Replies: 5
    Last Post: 10-20-2013, 09:45 PM
  3. IF ID Is not Null show TYPE from other table
    By superjeff in forum Access
    Replies: 5
    Last Post: 09-14-2012, 09:45 PM
  4. Multiple Queries With Same Type Of Data
    By thegooser in forum Access
    Replies: 4
    Last Post: 05-04-2012, 09:31 AM
  5. Data type mismatch error on all of my queries!
    By MarkGLyons in forum Queries
    Replies: 3
    Last Post: 12-27-2010, 01:27 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