Results 1 to 11 of 11
  1. #1
    nick.h is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    22

    Null Value prevents showing any results

    Hey,

    I have a query:
    Code:
    SELECT "Prospecting Calls" AS VisitType, Abs(Count(VisitDate)) AS Monday
    FROM VisitInfo
    WHERE (((VisitInfo.VisitDate)=GetTraxDate()) AND ((VisitInfo.AddedBy)=GetUser()) AND ((VisitInfo.FormOfContact)=3))
    GROUP BY "Prospecting Calls";
    Where if there is a Count of 0 then it returns as Null. I would like to put this into a report where there are several similar queries, but if any of the Counts are 0 then I get a blank form. How do I get it to display 0???



    Please Help!
    Nick

  2. #2
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481

    Question

    Can you tell if the problem is because the count is 0 or is it because some of the underlying VisitDate are null?
    When there is a chance of a field containing a null value, I use NZ(var,0) to insure there is a zero value in the field. Same thing applies to empty fields, although I haven't suffered as much from empty fields as I have from nulls.

  3. #3
    nick.h is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    22
    The count is 0. The problem is that there were no records added on that day, and therefore there is nothing for it to count.

  4. #4
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481
    How you solve this problem depends on where the query is in the report. As long as the query listed isn't the basis for the report, there should be a point at which you can intercept the null and take other action.
    Can you put some dummy data in your database, compact and post it? Zip it if necessary. Since I have Access 2007, I'm not sure that I can help.

  5. #5
    nick.h is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    22
    The report is 100% based on the query :/

  6. #6
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481
    Sounds like you will have to run the query from a form or macro, trap the null and doctor the data/query so the report will run.

  7. #7
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481

    On second thought, take the count out of the query on which the

    report is based. Use Dcount within the report to get the number you need.
    Google 'access Dcount'.

  8. #8
    nick.h is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    22
    Yep! DCount is the way to go! Thank you!

    I'm having issues with doing multiple Criteria. When I use:

    =DCount("VisitDate","VisitInfo","VisitDate = GetTraxDate()+2" And "FormOfContact = '2'")

    It simply counts everything, but when I remove the Part after "And" it filters properly. ???

    Nick

  9. #9
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    =DCount("VisitDate","VisitInfo","VisitDate = GetTraxDate()+2" And "FormOfContact = '2'")

    Try the following

    =DCount("VisitDate","VisitInfo","VisitDate = GetTraxDate()+2 And FormOfContact = '2'")

  10. #10
    nick.h is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    22
    It gave me #Error, but I'm going to kepe looking at your version and see if it's just a missing quote

  11. #11
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    I was looking at a syntax error, now I see this part of your description

    but when I remove the Part after "And" it filters properly. ???
    which indicates that the And FormOfContact = '2' isn't required.

    So try this
    =DCount("VisitDate","VisitInfo","VisitDate = GetTraxDate()+2")

    Does GetTraxDate() return a Date datatype?

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

Similar Threads

  1. Creating a report with null's not showing
    By brobb56 in forum Forms
    Replies: 55
    Last Post: 09-27-2011, 01:10 PM
  2. Not showing records with null sum
    By eww in forum Queries
    Replies: 3
    Last Post: 04-04-2011, 03:10 PM
  3. Replies: 1
    Last Post: 03-09-2011, 02:04 AM
  4. Query showing unexpected results
    By johnmerlino in forum Queries
    Replies: 30
    Last Post: 10-25-2010, 07:08 AM
  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