Results 1 to 13 of 13
  1. #1
    DianneBeck is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Apr 2015
    Posts
    18

    query that will total multiple expenditure amounts in several different accounts.


    We are using Access 2010 at work. I have developed a table with my budget figures for each account even those that have a zero value. In another table I am posting the daily expenditures. This will go from July 1st of each year through June 30th of the next year. There can be multiple postings to each expenditure account on different dates. I have written a query that will pull out the the month to date figures >03/31/2015 and < 05/01/2015. The problem is that it will not return a total for each expenditure account unless the date is the same. I would like the expenditure table to reflect the actual processing date. Is there a way I can get it to sum the amount column, with different processing dates?

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Please show readers your table(s) designs -- your fields, names, data types...
    It would also be helpful to show the query(sql view) you are using.

  3. #3
    DianneBeck is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Apr 2015
    Posts
    18
    Expenditure Table fields:
    Date
    Vendor Name
    Voucher number
    Fund
    Program
    Account
    Amount

    Query design, pulls from this table:
    Date (does not show in results) Criteria: >03/31/2015 and < 05/01/2015 (to pull mtd totals only)
    Fund
    Program
    Account
    Amount (Sum)

    When you run the query if there are multiple postings for the same account it does not return one total for the account and that is what I need it to do. The only way it will return one total is if the date is the same and I would prefer not to change the date to one date for the whole month.

  4. #4
    DianneBeck is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Apr 2015
    Posts
    18
    ID DATE VENDOR NAME VOUCHER NUMBER FUND PROGRAM ACCOUNT AMOUNT
    1 4/1/2015 APPALACHIAN POWER 1 01000 398015 5015420 $35,700.00
    2 4/10/2015 APPALACHIAN POWER 2 01000 398015 5015420 $1,500.00
    3 4/10/2015 APPALACHIAN POWER 3 01000 398015 5015420 $500.00

    FUND PROGRAM ACCOUNT SumOfAMOUNT
    01000 398015 5015420 $35,700.00
    01000 398015 5015420 $2,000.00

    I want the query to return a total of $37,700.00

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Please show the SQL for th that is different in the source data is the e query you did run. The only value I see Date value, so it seems you have some grouping on Date which is not needed, and is causing the aggregate records to appear as they do. Also DATE is a reserved word in Access.

  6. #6
    DianneBeck is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Apr 2015
    Posts
    18
    I realize Date is a reserved word in Access, however, the date is required since I will be posting items for 12 mos.

    I have tried and tried to copy my query into this post but it won't do it. I have not written any other SQL other than the sort on the date.

  7. #7
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Please excuse my previous post--seems the edits were misplaced?? I have adjusted it below.

    Please show the SQL for the query you did run. The only value I see that is different in the source data is value, so it seems you have some grouping on Date which is not needed, and is causing the aggregate records to appear as they do. Also DATE is a reserved word in Access.

    You can rename Date as MyDate or whatever.
    When you use the query wizard, go to SQL View and copy the code, then paste it into your post.
    Good luck.

  8. #8
    DianneBeck is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Apr 2015
    Posts
    18
    Okay I tried changing the date field to Post Date and it still does the same thing.

    I added a few more items to my table:
    ID POST DATE VENDOR NAME VOUCHER NUMBER FUND PROGRAM ACCOUNT AMOUNT
    1 4/1/2015 APPALACHIAN POWER 1 01000 398015 5015420 $35,700.00
    2 4/10/2015 APPALACHIAN POWER 2 01000 398015 5015420 $1,500.00
    3 4/10/2015 APPALACHIAN POWER 3 01000 398015 5015420 $500.00
    4 3/5/2015 JDM SERVICES 4 01000 398015 5015430 $2,000.00
    5 3/7/2015 APPALACHIAN 5 01000 398015 5015420 $33,000.00
    6 4/15/2015 DOC FARMERS MKT 6 01000 398007 5013620 $3,500.00
    7 4/17/2015 DOC AGRIBUSINESS 7 01000 398007 5013620 $2,000.00

    Here's the SQL view
    SELECT [mtd expenditures].FUND, [mtd expenditures].PROGRAM, [mtd expenditures].ACCOUNT, Sum([mtd expenditures].AMOUNT) AS SumOfAMOUNT
    FROM [mtd expenditures]
    GROUP BY [mtd expenditures].FUND, [mtd expenditures].PROGRAM, [mtd expenditures].ACCOUNT, [mtd expenditures].[POST DATE]
    HAVING ((([mtd expenditures].[POST DATE])>#3/31/2015# And ([mtd expenditures].[POST DATE])<#5/1/2015#));

    Here are the results I get:

    FUND PROGRAM ACCOUNT SumOfAMOUNT
    01000 398015 5015420 $35,700.00
    01000 398015 5015420 $2,000.00
    01000 398007 5013620 $3,500.00
    01000 398007 5013620 $2,000.00

    I need the query return a total of $37,700 for account 5015420
    and an amount of $7,500 for account number 5013620. All accounts will not have multiple postings for the month but some do.

  9. #9
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    I don't think you need to do the

    Group By mtd expenditures].[POST DATE]

    I believe this is what is giving you the separate amounts.

  10. #10
    DianneBeck is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Apr 2015
    Posts
    18
    I took out the group by as you instructed. I get the following error message

    Your query does not include the specified '[mtd expenditures,[POST DATE]> #03/31/2015# AND [mtd expenditures],[POST DATE] #< 05/01/2015# as part of an aggregate function.

    SQL VIEW:
    SELECT [mtd expenditures].FUND, [mtd expenditures].PROGRAM, [mtd expenditures].ACCOUNT, Sum([mtd expenditures].AMOUNT) AS SumOfAMOUNT
    FROM [mtd expenditures]
    GROUP BY [mtd expenditures].FUND, [mtd expenditures].PROGRAM, [mtd expenditures].ACCOUNT
    HAVING ((([mtd expenditures].[POST DATE])>#3/31/2015# And ([mtd expenditures].[POST DATE])<#5/1/2015#));

  11. #11
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Try thisuntested)
    SELECT [mtd expenditures].FUND, [mtd expenditures].PROGRAM, [mtd expenditures].ACCOUNT, Sum([mtd expenditures].AMOUNT) AS SumOfAMOUNT
    FROM [mtd expenditures]
    WHERE ([mtd expenditures].[POST DATE]>#3/31/2015#) And ([mtd expenditures].[POST DATE]<#5/1/2015#)
    GROUP BY [mtd expenditures].FUND, [mtd expenditures].PROGRAM, [mtd expenditures].ACCOUNT;

  12. #12
    DianneBeck is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Apr 2015
    Posts
    18
    It works!!!!!!!!!!!!!!!!!!!!!!!!!

    Thank you....Thank you!!!!!!!!!!!!!

  13. #13
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870

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

Similar Threads

  1. Replies: 1
    Last Post: 02-23-2015, 01:19 AM
  2. Income and Expenditure
    By azhar2006 in forum Access
    Replies: 3
    Last Post: 07-17-2014, 02:30 PM
  3. Replies: 17
    Last Post: 11-06-2013, 05:38 PM
  4. Replies: 8
    Last Post: 04-29-2013, 12:11 PM
  5. How to create an accounts table?
    By Gman11 in forum Access
    Replies: 5
    Last Post: 10-12-2011, 06:43 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