+ Reply to Thread
Results 1 to 15 of 15

Microsoft Access Database between dates to give total summary

  1. #1
    Registered User
    Join Date
    04-02-2020
    Location
    australia
    MS-Off Ver
    Professional PLus 2016
    Posts
    22

    Microsoft Access Database between dates to give total summary

    Hi All,
    I'm kind of new on Microsoft access database and I'm trying to create a query from table to have e.g. "Client Code", "Client Name", "Net Total", "Gross Total", "Percentages", but each time I enter between dates 01/07/2022 - 30/06/2023 & group this and sum for "Net Total" & "Gross Total" it give me each date line. I need as per pic. I just want this as 1 qry.
    Access sum total.JPG

    I think I attached the excel file file. if not please let me know how to do this?

    Thanks in advance.
    Kitsa
    Attached Files Attached Files
    Last edited by Kitsa; 08-15-2023 at 05:48 PM. Reason: add more details

  2. #2
    Registered User
    Join Date
    05-16-2013
    Location
    United Kingdom
    MS-Off Ver
    Office 2007
    Posts
    20

    Re: Microsoft Access Database between dates to give total summary

    Group by Client Code
    https://support.microsoft.com/en-us/...ngle%20record.

  3. #3
    Registered User
    Join Date
    04-02-2020
    Location
    australia
    MS-Off Ver
    Professional PLus 2016
    Posts
    22

    Re: Microsoft Access Database between dates to give total summary

    Hi Welshgasman,
    I don't understand SQL so I don't know what needs to happen? Can you send me a sample code?

    Thanks
    Kitsa

  4. #4
    Registered User
    Join Date
    05-16-2013
    Location
    United Kingdom
    MS-Off Ver
    Office 2007
    Posts
    20

    Re: Microsoft Access Database between dates to give total summary


  5. #5
    Registered User
    Join Date
    04-02-2020
    Location
    australia
    MS-Off Ver
    Professional PLus 2016
    Posts
    22

    Re: Microsoft Access Database between dates to give total summary

    Hi Welshgasman,
    I have looked at everything and I still can't get the result I'm after. Still shows each line. Are you able to help me to fix this coding?

    Please Login or Register  to view this content.
    Thanks
    Kitsa

  6. #6
    Registered User
    Join Date
    05-16-2013
    Location
    United Kingdom
    MS-Off Ver
    Office 2007
    Posts
    20

    Re: Microsoft Access Database between dates to give total summary

    I generally use the QBE window and design mode. TBH most of my queries are trial and error.
    This is a query of mine that shows me the carb,sugar and fibre totals per day for my diabetes DB.

    Please Login or Register  to view this content.
    Note, I use a WHERE and then GROUP BY, whereas you are using GROUP BY and HAVING.

    Also good videos on Youtube on a lot os aspects of Access.

    https://www.youtube.com/watch?v=YBwGcslqP00

    Try
    Please Login or Register  to view this content.
    However True and False are logical states, not strings as you have there?
    Also any time the grouping changes, then you will get a new group. So if your dates are different per record, that would cause that? It is unlikely the amounts would remain the same, so that would be another group.
    You can see from my sql that I group by a weeknum, so all records for that week (and there will be several per day) are summed to give me a daily total.

    https://www.google.com/search?q=sql+...hrome&ie=UTF-8

  7. #7
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Microsoft Access Database between dates to give total summary

    It's because you've got the tbl_masterdata.date in your Group By clause, it shouldn't be. And welshgasman is correct, your filter should be in your where clause, not the Having clause

  8. #8
    Registered User
    Join Date
    04-02-2020
    Location
    australia
    MS-Off Ver
    Professional PLus 2016
    Posts
    22

    Re: Microsoft Access Database between dates to give total summary

    sorry guys but I'm at a loss, I can't work this out and I'm no good with coding. Just need the answers in one query, what am I doing wrong.
    I used the coding you suggested.

    Please Login or Register  to view this content.
    Last edited by AliGW; 08-23-2023 at 03:39 AM. Reason: Code tags corrected.

  9. #9
    Registered User
    Join Date
    05-16-2013
    Location
    United Kingdom
    MS-Off Ver
    Office 2007
    Posts
    20

    Re: Microsoft Access Database between dates to give total summary

    You are still including date? take the date field out of the GROUP clause.
    I also doubt you need to GROUP by the Gross Amount.

    Any time any of the group by elements are different, you will get a different group.

    From your initial picture I would expect GROUP by ClientCode is all you need.
    Last edited by AliGW; 08-23-2023 at 03:39 AM. Reason: Please do NOT quote unnecessarily! Use the QUICK REPLY button instead.

  10. #10
    Registered User
    Join Date
    04-02-2020
    Location
    australia
    MS-Off Ver
    Professional PLus 2016
    Posts
    22

    Re: Microsoft Access Database between dates to give total summary

    Welshgasman the code now works with the sum total as per pic but now I'm trying to get the percentage and it's come up wrong. I needed the gross amount / the tot sum of gross amount. What have I done wrong now?

    Please Login or Register  to view this content.
    Access sum total with percentage.JPG
    Last edited by Kitsa; 08-23-2023 at 06:30 AM.

  11. #11
    Registered User
    Join Date
    05-16-2013
    Location
    United Kingdom
    MS-Off Ver
    Office 2007
    Posts
    20

    Re: Microsoft Access Database between dates to give total summary

    Well it is likely due to your Dsum(), it does not have the same criteria as your WHERE clause?, so you are summing everything?

  12. #12
    Registered User
    Join Date
    04-02-2020
    Location
    australia
    MS-Off Ver
    Professional PLus 2016
    Posts
    22

    Re: Microsoft Access Database between dates to give total summary

    So how would I do this if I already have a "Where" code and Dsum() won't work?

  13. #13
    Registered User
    Join Date
    05-16-2013
    Location
    United Kingdom
    MS-Off Ver
    Office 2007
    Posts
    20

    Re: Microsoft Access Database between dates to give total summary

    I can only think of two ways.
    The first is to put the same criteria into the DSum(), but that is likely to be difficult syntactically, and Domain aggregate functions are not recommended in queries anyway.
    The second is to have another query that sums the amounts with exactly the same criteria.

    Then bring that query into this query (do not join them) and bring in the total field. Then you can reference them in your calculation for percentage.

    I have just tested option 2 on a db of mine and that appears to work.
    Attached Images Attached Images

  14. #14
    Registered User
    Join Date
    04-02-2020
    Location
    australia
    MS-Off Ver
    Professional PLus 2016
    Posts
    22

    Re: Microsoft Access Database between dates to give total summary

    Hi Welshgasman,
    What you said worked and I finally got it from all your help.

    Thanks heaps, couldn't have done it without ya.
    Please Login or Register  to view this content.

  15. #15
    Registered User
    Join Date
    05-16-2013
    Location
    United Kingdom
    MS-Off Ver
    Office 2007
    Posts
    20
    Are you sure, as everything appears to come from query2, not two queries as I mentioned?
    Plus there shouldbeno need for all those group elements?, just billto should be enough if that is some sort of client code?
    Last edited by AliGW; 08-24-2023 at 05:24 AM. Reason: Please do NOT quote unnecessarily!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Send info of specific cells to Microsoft ACCESS database
    By luiscp in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-20-2020, 11:19 PM
  2. Is it safe or ideal to use Microsoft Access as a Database for 15 employees?
    By jdcortez in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-01-2019, 05:08 AM
  3. [SOLVED] Microsoft office 14.0 access database engine object library
    By ColemanJames in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-12-2017, 01:00 PM
  4. SQL database in local PC need to give access to some other users.
    By ali84pk in forum Access Tables & Databases
    Replies: 9
    Last Post: 07-30-2015, 12:11 PM
  5. [SOLVED] EXCEL conditional formatting on Microsoft access database not working
    By cascencio83 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 03-03-2015, 11:19 PM
  6. Open an Access database Import data like Microsoft Query
    By hilander in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-28-2007, 06:55 PM
  7. [SOLVED] Microsoft Access database
    By Tracy in forum Excel General
    Replies: 2
    Last Post: 08-06-2005, 01:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1