Results 1 to 8 of 8
  1. #1
    Ludovik is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2013
    Posts
    11

    Adding "Count" Totals to Report

    Hey All,


    I'm glad I stumbled upon this site, lots of useful stuff. Anyhow, I'm fairly new to Access and two separate yet related issues. I can't upload the DB since it's hosted online but I'll try to be as descriptive as possible.
    Click image for larger version. 

Name:	ChinookDatabaseSchema1_1.png 
Views:	8 
Size:	41.4 KB 
ID:	14266

    Case One

    I am trying to make a query that shows how many artists have songs with the word "love" in the title and then make a report that shows a count of the result. This is my query design:

    Click image for larger version. 

Name:	tracks_query.jpg 
Views:	9 
Size:	74.7 KB 
ID:	14268

    What happens when I run the query though is that each track is counted separately; the results look like:

    Click image for larger version. 

Name:	track_count.jpg 
Views:	9 
Size:	12.8 KB 
ID:	14269

    When what I'm looking for is a total of the count. I've tried for about two/three hours to figure out how to get it to work but I'm obviously missing something obvious.

    Any help from the community would be more than appreciated.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    You do not have an artist id in your track table. This is why you see a count of 1

    Build another query. Place dbo_Album and dbo_Track in the query. Make a relationship. Edit the properties of the relationship to show "All of the records in Album". Your goal is to create a SELECT query.

    Now place the new query in your Tracks_With_Word_Love_Query. You will have the Artist table and the new query. Create the relationship to Artist ID "One to Many" and try to get your count then.

  3. #3
    Ludovik is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2013
    Posts
    11
    Is there a way to accomplish this by using only one query? For example, adding tables/relationships to my original query such that each artist only shows once? If I understand you correctly, the problem is that in the "dbo_Track" table there is no key to uniquely identify each artist. I don't mean to seem dense or anything.

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    If you want to count the number of tracks associated with a specific artist, you will need to create a relationship between tracks and artists. You can do this in a single SQL statement. You can create this statement by starting with a separate query of Albums and tracks. This separate query will have the Artist ID you will need to create the single SQL statement.

  5. #5
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Ludovik - Don't GROUP BY the track name. Your count will always be 1 unless the artist has the same track name on two different albums.

    Itsme - The visual query design screen fooled you. (I prefer reading the SQL too.) According to that design view image, it's already a three-table join, so the relationship between track and artist is already established via inner joins, track to album and album to artist. Ludovik just hasn't asked for any album fields in the query result, which makes it unclear that the dbo_album table is in the join.

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    @ Dal

    So remove the fields and just include "Name" from the Artist table twice? Once for display and once to count?

  7. #7
    Ludovik is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2013
    Posts
    11
    Solution was simpler than all of that; after tinkering for about another hour all I had to do was change one value (see attached image).Click image for larger version. 

Name:	report_solution.png 
Views:	8 
Size:	3.0 KB 
ID:	14271

  8. #8
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Yep. He gots it.

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

Similar Threads

  1. Using "Count" function in a report footer
    By GraeagleBill in forum Reports
    Replies: 5
    Last Post: 05-11-2013, 03:42 PM
  2. Export "Query or Report" to a "Delimited Text File"
    By hawzmolly in forum Import/Export Data
    Replies: 3
    Last Post: 08-31-2012, 08:00 AM
  3. Replies: 1
    Last Post: 08-23-2012, 08:32 AM
  4. Query Results "Count Totals"
    By tipopilotas in forum Queries
    Replies: 1
    Last Post: 03-26-2010, 10:36 PM
  5. "Count" and "Countif" in Reports
    By JMantei in forum Reports
    Replies: 1
    Last Post: 06-20-2006, 02:20 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