Results 1 to 4 of 4
  1. #1
    shank is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Sep 2010
    Posts
    188

    Return value for NULL query results

    In the below, I'm counting orders with multiple product lines in table Temp. In table TEMP, there will be duped invoice numbers indicating multiple lines. When there's >1, no problem. When there's <=1, I can only get a return of NULL. I'm trying to display a value of 0 for both columns. What am I doing wrong?

    Code:
    SELECT Nz([Temp]![InvNo],0) AS InvNo, Nz(Count([Temp]![InvNo]),0) AS InvNoCount
    FROM Temp
    GROUP BY Nz([Temp]![InvNo],0)
    HAVING (((Nz(Count([Temp]![InvNo]),0))>1))
    ORDER BY Nz([Temp]![InvNo],0), Nz(Count([Temp]![InvNo]),0);

    Thanks!

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    make Q1 to convert all nulls to 0.
    then use Q2 (which uses Q1) as the reporting query.

  3. #3
    shank is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Sep 2010
    Posts
    188
    Understood.

    Thanks!

  4. #4
    shank is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Sep 2010
    Posts
    188
    I needed to come back to this. Now I'm having issues getting a value if a field is either "" or IsNull.

    All the below statements give me no results.

    InvCount: IIf([InvNoCount]="" Or IsNull([InvNoCount]),0,1)

    InvCount: IIf([InvNoCount]="" Or IsNull([InvNoCount])=True,0,1)

    InvCount: Nz([InvNoCount],0)

    What am I doing wrong?

    Thanks!

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

Similar Threads

  1. How to return a Zero instead of null in query
    By greidy78 in forum Queries
    Replies: 1
    Last Post: 04-30-2019, 12:27 PM
  2. How to get a query to return results for null/0 value?
    By NikoTheBowHunter in forum Queries
    Replies: 8
    Last Post: 08-28-2018, 09:04 AM
  3. Replies: 6
    Last Post: 04-04-2017, 02:50 AM
  4. Union Query to return Null
    By dr4ke in forum Queries
    Replies: 8
    Last Post: 07-06-2012, 12:18 AM
  5. Query return 0 for null values
    By rachello89 in forum Access
    Replies: 4
    Last Post: 02-23-2012, 08:38 AM

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