Results 1 to 2 of 2
  1. #1
    hyperionfall is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    mississippi
    Posts
    18

    use 0 for null value in count query

    I have this:



    SELECT Count([TETHERlogHISTORY].[DATEOFRETERM]) AS [CountOfDATEOFRETERM]
    FROM [TETHERlogHISTORY]
    GROUP BY DateDiff("d",[DATEOFRETERM],Now())
    HAVING (((DateDiff("d",[DATEOFRETERM],Now()))<7));

    I need the query to show 0 if it returns a null value.

    i tried this:

    SELECT Nz(Count([TETHERlogHISTORY].[DATEOFRETERM]), 0) AS [CountOfDATEOFRETERM]
    FROM [TETHERlogHISTORY]
    GROUP BY DateDiff("d",[DATEOFRETERM],Now())
    HAVING (((DateDiff("d",[DATEOFRETERM],Now()))<7));

    but it did not work.

    any ideas?

    thanks

  2. #2
    hyperionfall is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    mississippi
    Posts
    18

    got it fixed

    nevermind i got it...

    SELECT Nz(Count([TETHERlogHISTORY].[DATEOFRETERM]), 0) AS [CountOfDATEOFRETERM]
    FROM [TETHERlogHISTORY]
    GROUP BY DateDiff("d",[DATEOFRETERM],Now())
    HAVING (((DateDiff("d",[DATEOFRETERM],Now()))<7));


    GROUP BY DateDiff("d",[DATEOFRETERM],Now())
    this was the culprit...removed the grouping (cant remember why it was there in the first place...bingo it worked fine now

    any idea why the grouping would cause that?

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

Similar Threads

  1. Query and if null
    By robmict in forum Queries
    Replies: 5
    Last Post: 07-14-2010, 05:04 PM
  2. If Query result Is Null...MsgBox..Okl
    By Bruce in forum Forms
    Replies: 28
    Last Post: 03-10-2010, 10:57 AM
  3. Null Values in query
    By LesleaOH in forum Queries
    Replies: 0
    Last Post: 10-19-2009, 04:45 PM
  4. Query including Null relationship?
    By David Criniti in forum Database Design
    Replies: 0
    Last Post: 08-14-2009, 09:10 PM
  5. Null Values not showing up in a Query
    By Valli in forum Queries
    Replies: 0
    Last Post: 01-04-2006, 03:53 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