Results 1 to 9 of 9
  1. #1
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398

    using DCount instead of a recordset

    I've created a recordset to determine a recordcount. Here is my SQL string:
    SELECT PC_Log.ReportDate FROM PC_Log
    GROUP BY PC_Log.ReportDate, Left([Request Number],4)
    HAVING (((Left([Request Number], 4)) = 'FY14'))

    Is it possible to use DCount instead? I can't figure out how to use the "GROUP" within the DCount statement.



    Thank you in advance!!

  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,521
    Presuming you're counting the dates, the criteria should handle it.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398
    I can't figure out the syntax.

    Here's what my data looks like:

    Request Number,ReportDate
    FY14-001, 07/12/13
    FY14-002, 07/12/13
    FY14-003, 07/26/13
    FY14-004, 07/26/13
    FY14-005, 07/26/13
    FY14-006,08/09/13

    Using DCount, it should be 3.
    Last edited by crowegreg; 10-07-2013 at 05:28 PM. Reason: typo

  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,521
    What have you got so far? I assume you also have a date criteria to get 3.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398
    Here's what I have:
    intRecordCount = DCount("[ReportDate]", "PC_Log", "Left([Request Number], 4) = '" & strFYYear & "'")

    strFYYear = "FY14"

    With the data above, I'm returning 6. I need 3.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Well, there are 6 records with that criteria, so which 3 are you expecting it to count?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Oh, I get it, you want that there are 3 distinct dates? I don't think you can get that directly from the table, but you could apply a DCount() to a query with that SQL.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398
    I'm trying to retrieve distinct dates.
    07/12/13
    07/26/13
    08/09/13

    count of 3

  9. #9
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398
    That's what I didn't know. When this is executed, which takes less time, creating a recordset, or creating a querydef, then using DCount with the query?

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

Similar Threads

  1. How to Select second Recordset from first recordset
    By FrustratedAlso in forum Programming
    Replies: 28
    Last Post: 05-10-2012, 05:45 PM
  2. Replies: 2
    Last Post: 03-08-2012, 12:59 PM
  3. DCount and If
    By Madmax in forum Access
    Replies: 3
    Last Post: 07-28-2011, 06:53 AM
  4. Help with Dcount
    By tozey in forum Programming
    Replies: 1
    Last Post: 08-10-2010, 10:53 AM
  5. Replies: 1
    Last Post: 11-13-2009, 03:03 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