Results 1 to 5 of 5
  1. #1
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,191

    Recordset Sum


    Can I add a sum in the line some where ? ie: Sum CostOfJob and Sum VAT and Sum Total ??

    Code:
    Set rs = CurrentDb.OpenRecordset("Select tblInvoices.InvoiceDate, tblInvoices.Name, tblInvoices.InvoiceNumber, tblInvoices.CostOfJob, tblInvoices.VAT, tblInvoices.Total, tblInvoices.Paid, tblInvoices.PaidDate From tblInvoices WHERE InvoiceDate Between #" & mStartDate & "# And #" & mEndDate & "# ORDER BY InvoiceDate;")

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,896
    Only if you make it an aggregate (GROUP BY) query. Total is not a field so how can you sum it?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,191
    Hi June7 thank you for your reply, total is a field i am looking for the following

    CostOfJob (Sum)
    VAT (Sum)
    Total (Sum)

    Then if there is x 4 names (customers) within that period, this means there is x 4 Invoices for that customer, i am looking to our put to excel the following

    From
    Joe Bloggs CostOfJob £20.00 VAT £5.00 Total £25.00
    Joe Bloggs CostOfJob £20.00 VAT £5.00 Total £25.00
    Joe Bloggs CostOfJob £20.00 VAT £5.00 Total £25.00
    Joe Bloggs CostOfJob £20.00 VAT £5.00 Total £25.00

    To:

    Joe Bloggs CostOfJob £80.00 VAT £20.00 Total £100.00

    Hope this makes sense ?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,896
    Ooops, I missed the Total field in the SQL.

    Advise still applies. Use an aggregate (GROUP BY) query or build report. Report allows display of detail data as well as summary calcs.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,191
    Hi June7, yes it make sense to add criteria's and sums to query and pick up from that

    Thank you very much

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

Similar Threads

  1. Replies: 4
    Last Post: 01-22-2015, 09:57 AM
  2. Replies: 6
    Last Post: 12-03-2013, 11:14 PM
  3. How to Select second Recordset from first recordset
    By FrustratedAlso in forum Programming
    Replies: 28
    Last Post: 05-10-2012, 05:45 PM
  4. Replies: 2
    Last Post: 03-08-2012, 12:59 PM
  5. Replies: 1
    Last Post: 11-13-2009, 03:03 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