Results 1 to 7 of 7
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    2,095

    Can't get GROUP BY to work

    I want to display a list of descriptions taken from a table, "tblRegister". I'm attempting to use the GROUP BY phrase to suppress duplication. Below is a screenshot of the SQL view of the query and the diagnostic that accompanies my last attempt.



    Click image for larger version. 

Name:	000.jpg 
Views:	12 
Size:	58.2 KB 
ID:	26817

    What's the problem here?

  2. #2
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    It looks like you typed that last bit in. Rather let Access do it for you. Remove that line, go to Design view and click on the Totals icon. Then you will see what to fill in.

  3. #3
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    A few things:

    1. When using Aggregate Queries, every field in your SELECT clause must either be "GROUPED" (show up in the "GROUP BY" clause), or have an Aggregate Function applied to it (i.e. SUM, MAX, etc).
    So you have three fields in your SELECT clause that you need to do something with.

    2. ORDER BY comes at the very end, after the GROUP BY clause.

  4. #4
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    2,095
    Following JoeM suggestion I created the following. The query runs as desired. I want to run the query as the RowSource of a combo box. How do I filter the "TDate" and "TTypeID" in the query............ other than building the SQL in code and updating the query def?

    Click image for larger version. 

Name:	003.jpg 
Views:	12 
Size:	44.9 KB 
ID:	26819
    Attached Thumbnails Attached Thumbnails 003.jpg  

  5. #5
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    2,095
    Oops! The "Count" design view is by mistake and should not have been included.

  6. #6
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    2,095
    Oops! The "Count" design view is by mistake and should not have been included.

  7. #7
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    2,095
    I'll take the SQL generated by the query design and make the appropriate substitutions for "TDate" and "TTypeID" in code and set the RowSource for the combo box.

    Thanks for the help,
    Bill

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

Similar Threads

  1. Replies: 6
    Last Post: 06-09-2015, 09:51 AM
  2. Replies: 4
    Last Post: 12-06-2014, 08:49 PM
  3. Replies: 2
    Last Post: 09-23-2014, 08:36 AM
  4. Group by month - can't get it to work !
    By SpookiePower in forum Queries
    Replies: 4
    Last Post: 12-15-2013, 04:47 PM
  5. Replies: 0
    Last Post: 02-25-2013, 04:43 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