Results 1 to 3 of 3
  1. #1
    brunor is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    2

    DCount with Date Grouping


    I am using the following textbox to count records within a report group header:
    =DCount("[ID]","Query1","[Text] = " & "Text30"), where "Text30" is the grouping criteria and is displayed in the group header. This format works well, but I would like to use something similar to group by month with a [Date] field: =DCount("[ID]","Query1","[Date] = " & "??????").
    I have tried multiple variations of syntax without success. Any suggestions would be appreciated.
    Thanks.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Is Text30 literal text or a field name?

    If is text, no need to concatenate:
    =DCount("[ID]","Query1","[Text] = 'Text30'")

    If is fieldname and text datatype:
    =DCount("[ID]","Query1","[Text] = '" & [Text30] & "'")


    Use Date/Time functions to manipulation date values. You want to group by month (and I assume also year), extract the Month and Year with: Month([Date]) & Year([Date])

    Use the expression as GROUP BY criteria.

    The DCount would be like:
    =DCount("[ID]","Query1","Month([Date]) & Year([Date]) = some value like 122011")

    =DCount("[ID]","Query1","Month([Date]) & Year([Date]) = " & Month([Date] & Year([Date]))
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    brunor is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    2
    As you suggested, I used this to count the records grouped by month/year:
    =DCount("[ID]","Query1","Month([Date]) & Year([Date]) = " & Month([Date]) & Year([Date])).

    It works perfectly.
    Thank you very much.
    BR

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

Similar Threads

  1. DCount and If
    By Madmax in forum Access
    Replies: 3
    Last Post: 07-28-2011, 06:53 AM
  2. Replies: 5
    Last Post: 06-22-2011, 08:47 PM
  3. Using a date range with Dcount function
    By mleberso in forum Reports
    Replies: 4
    Last Post: 06-17-2011, 08:56 AM
  4. Replies: 9
    Last Post: 01-28-2011, 06:05 PM
  5. DCount and SQL
    By DSTR3 in forum Queries
    Replies: 3
    Last Post: 12-06-2010, 03:07 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