Results 1 to 4 of 4
  1. #1
    Chris1112 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Mar 2012
    Posts
    31

    Count or DCount Not Working Properly


    In a textbox on the Form Footer, I'm trying to count the number of records that meet a criteria. In using Count in one and DCount in the other. Here's my formula.

    Code:
    =Count([MaxOfSTAGE]<2)
    =DCount("[MaxOfSTAGE]","qryCAData","[MaxOfSTAGE] < 2")
    qryCAData is the query that the record source for the form. [MaxOfSTAGE] is a required numeric field. Count displays the total number of records, ignoring criteria, and DCount always gives me zero. Any help on what could be happening here?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,198
    Count doesn't have a criteria. Try

    =Sum(IIf([MaxOfSTAGE]<2, 1, 0))

    The DCount() looks fine, so double check your values. You might try:

    =DCount("*","qryCAData","[MaxOfSTAGE] < 2")
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Chris1112 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Mar 2012
    Posts
    31
    I need to be slapped. Your Sum appears to work but I jus realized that the DCount was working. None of my sample data had a MaxOfSTAGE value below 2.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,198
    Okay, where do you live? I'll send over the nearest slapper.

    Glad you got it sorted out.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Alternate Back Color not working properly
    By kolarbr in forum Access
    Replies: 7
    Last Post: 08-30-2011, 10:16 AM
  2. Msgbox And Search Code Not Working Properly
    By vampyr07au in forum Forms
    Replies: 1
    Last Post: 05-02-2011, 05:16 PM
  3. Replies: 1
    Last Post: 12-02-2010, 11:08 PM
  4. Delete SQL statement not working properly
    By Alexandre Cote in forum Programming
    Replies: 3
    Last Post: 10-18-2010, 12:56 PM
  5. Query on chart not working properly!
    By Sim_ in forum Queries
    Replies: 0
    Last Post: 10-28-2009, 09:38 AM

Tags for this Thread

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