Results 1 to 7 of 7
  1. #1
    Elwood07 is offline Novice
    Windows 7 32bit Access 2010 64bit
    Join Date
    Jun 2015
    Posts
    29

    Need Query to stop grouping by Date!

    Hi,

    I have a query that requires a date range input, so I've added the transaction date to the query fields and added a parameter, but it does not show on the query output.
    The query results show personnel number, ssn, name and total gratuity.


    I need the query to sum by each person's name or personnel number, but it looks like it is keeping them separated by date.
    In the design i've chosen Sum totals, and every field defaults to "Group By". I've changed my gratuity to "Sum", but it won't allow me to delete the group date on the transaction date field.

    I can't have duplicate names show on this list.
    Any help would be great!

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Can you change your query to SQL View, and copy and paste the SQL code here for us to see?

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,648
    Does the date field have WHERE instead of GROUP BY?

    What do you mean by 'delete the group date'?

    Could build a report and use its Sorting & Grouping features with aggregate calcs in group and report footer sections. This will allow display of detail records as well as summary data.
    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.

  4. #4
    Elwood07 is offline Novice
    Windows 7 32bit Access 2010 64bit
    Join Date
    Jun 2015
    Posts
    29
    Here it is with the Sum Total

    Code:
    SELECT tblPayee.SAPID AS [Personnel Number], "" AS SSN, tblPayee.PayeeName, tblOutlet.CostCenter AS [Cost Center], "" AS [Rate Override], Sum(tblPayee.GratuityAmount) AS 7550
    FROM (tblServer INNER JOIN (tblOutlet INNER JOIN tblOutletServer ON tblOutlet.OutletName = tblOutletServer.OutletName) ON tblServer.ServerID = tblOutletServer.ServerID) INNER JOIN (tblPayee INNER JOIN tblServerPayee ON tblPayee.PayeeID = tblServerPayee.PayeeID) ON tblServer.ServerID = tblServerPayee.ServerID
    GROUP BY tblPayee.SAPID, "", tblPayee.PayeeName, tblOutlet.CostCenter, "", tblServer.TransDate
    HAVING (((tblServer.TransDate) Between [Begin Date Range:] And [End Date Range:]))
    ORDER BY tblPayee.PayeeName;
    Thanks for looking into!

  5. #5
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Try moving your Date criteria out of the "HAVING" clause and enter it into a WHERE clause, and remove the date from your GROUP BY clause, since it is not in your SELECT clause. You also do not need to include any blanks or hard-coded values in your GROUP BY clause, i.e.
    Code:
    SELECT tblPayee.SAPID AS [Personnel Number], "" AS SSN, tblPayee.PayeeName, tblOutlet.CostCenter AS [Cost Center], "" AS [Rate Override], Sum(tblPayee.GratuityAmount) AS 7550
    FROM (tblServer INNER JOIN (tblOutlet INNER JOIN tblOutletServer ON tblOutlet.OutletName = tblOutletServer.OutletName) ON tblServer.ServerID = tblOutletServer.ServerID) INNER JOIN (tblPayee INNER JOIN tblServerPayee ON tblPayee.PayeeID = tblServerPayee.PayeeID) ON tblServer.ServerID = tblServerPayee.ServerID
    WHERE (((tblServer.TransDate) Between [Begin Date Range:] And [End Date Range:]))
    GROUP BY tblPayee.SAPID, tblPayee.PayeeName, tblOutlet.CostCenter
    ORDER BY tblPayee.PayeeName;

  6. #6
    Elwood07 is offline Novice
    Windows 7 32bit Access 2010 64bit
    Join Date
    Jun 2015
    Posts
    29
    That was so amazing, Thank You for your quick fix!

    Do you know why, even though I have a grand total set up to show on the query result (and it does), when I export it, the grand total won't show up. I did at one point, but along the way with the fiddling around I've been doing, it no longer exports. Is there another quick fix to that, do you think?

    Thanks Again!

  7. #7
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    I don't work too much with using Grand Totals within queries, but how exactly are you exporting the query?
    What file type are you exporting it to?

    Note. If you were using the Query Builder to build your query, the way that you would do what I do in the SQL code directly is under your Date field, uncheck the "Show" box and change the Totals row value from "Group By" to "WHERE".

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

Similar Threads

  1. Grouping By Week Using a Fixed Start Date
    By abinboston in forum Queries
    Replies: 1
    Last Post: 07-31-2014, 11:55 AM
  2. DCount with Date Grouping
    By brunor in forum Reports
    Replies: 2
    Last Post: 09-30-2011, 08:05 PM
  3. Replies: 5
    Last Post: 06-22-2011, 08:47 PM
  4. Replies: 9
    Last Post: 01-28-2011, 06:05 PM
  5. Replies: 2
    Last Post: 11-29-2009, 12:00 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