Results 1 to 6 of 6
  1. #1
    dcf1999 is offline Novice
    Windows 10 Access 2016
    Join Date
    Dec 2018
    Posts
    8

    Help with totals query

    So I have a table and I'm trying to get totals for different fields per year. So it's for a fire department program I'm creating. The user enters data for each call made. There is a lot of data to enter into the table but the main items I'm trying to total are calls that are accidents, how many patient refusals, how many patient transports, and the amount of calls to the local college. I want the query grouped by year, then calculate the amount of each field for that year. I cannot, for the life of me, get this to work. Obviously I'm doing something wrong. This seems like such a simple query. Maybe I'm using the wrong type of query? I attached pictures of what I'm trying to do. The fields [kish] and [mva] are yes/no fields. The other two are number fields.



    I want this query to be able to make a graph. I figured making a query first is the easiest thing to do.

    Click image for larger version. 

Name:	QueryDesign.jpg 
Views:	13 
Size:	65.0 KB 
ID:	43776Click image for larger version. 

Name:	Results.jpg 
Views:	13 
Size:	22.8 KB 
ID:	43777

  2. #2
    dcf1999 is offline Novice
    Windows 10 Access 2016
    Join Date
    Dec 2018
    Posts
    8
    Ok so the sum works on the table, but it's not counting the amount of "checked boxes" for mva and kish

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,906
    Use an IIF() function to test if the field is True, and then set to 1 or 0 if True or False.
    Then use SUM() on that expression NOT Count
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  4. #4
    dcf1999 is offline Novice
    Windows 10 Access 2016
    Join Date
    Dec 2018
    Posts
    8
    So I did this to the query and it seems to pull the correct values... I have a feeling it's not the best way.. but it works... I just don't want it to pull corrupt data.

    Basically I summed the yes/no fields and it gives me a negative number (since a true is -1) then use the abs function to turn that into a positive number. Click image for larger version. 

Name:	Results2.jpg 
Views:	12 
Size:	73.3 KB 
ID:	43778

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,906
    Just as good.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  6. #6
    ssanfu is offline Master of Nothing
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Be aware that "Type" is a reserved word in Access and shouldn't be used as an object name.
    Shouldn't use spaces on object names. (objects include fields, tables, queries, forms, reports, modules)
    Names should be only letters and numbers (exception is the underscore). Do not begin a name with a number.

    Problem names and reserved words in Access

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

Similar Threads

  1. Replies: 16
    Last Post: 01-19-2017, 08:14 AM
  2. Query detail totals vs. Summary Totals do not match?
    By aellistechsupport in forum Queries
    Replies: 9
    Last Post: 01-15-2016, 11:36 AM
  3. Unusual Sub Totals & Totals in Groups.
    By Robeen in forum Reports
    Replies: 12
    Last Post: 03-20-2012, 08:55 AM
  4. Replies: 5
    Last Post: 12-06-2011, 11:18 AM
  5. Month totals and Year totals
    By marksnwv in forum Access
    Replies: 1
    Last Post: 08-05-2011, 10:13 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