Results 1 to 4 of 4
  1. #1
    brownpride is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2016
    Posts
    10

    Total Row when e-mailing query result in excel format

    I have this Query....

    Code:
    SELECT [Deals Summary].[Deal ID], [Date], Format([Time],"hh:mm AM/PM") as [Trade Time], [Traders].[Trader], [Brokerage Clients].[Company Name], Format([Deals Summary].[Total Quantity],'###,###,###') as Quantity, Format([Period],'mmm yyyy') as Term, [Premium], [Deals Summary].[Total (Buying)] as Brokerage
    FROM (([Brokerage Clients] INNER JOIN [Deals Summary] 
    ON [Brokerage Clients].[Brokerage ID] = [Deals Summary].[Brokerage ID (Buyer)]) 
    INNER JOIN [Traders] ON [Deals Summary].[Trader ID (Buyer)] = [Traders].[Trader ID])
    WHERE [Deals Summary].[Date] = Date()
    
    
    UNION ALL SELECT [Deals Summary].[Deal ID], [Date], Format([Time],"hh:mm AM/PM") as [Trade Time], [Traders].[Trader], [Brokerage Clients].[Company Name], Format([Deals Summary].[Total Quantity],'###,###,###') as Quantity, Format([Period],'mmm yyyy') as Term, [Premium], [Deals Summary].[Total (Selling)] as Brokerage
    FROM (([Brokerage Clients] INNER JOIN [Deals Summary]
    ON [Brokerage Clients].[Brokerage ID] = [Deals Summary].[Brokerage ID (Seller)]) 
    INNER JOIN [Traders] ON [Deals Summary].[Trader ID (Seller)] = [Traders].[Trader ID])
    WHERE [Deals Summary].[Date] = Date();
    I currently have VBA code to send it via email which is working perfectly fine. However, I would like to sum the Brokerage column and show the result either in the excel file or the email text itself. If I manual export it via Access, the totals stay. But if I export using VBA, then the totals don't show up. Any help would be appreciated.

  2. #2
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,511
    Maybe in email code:
    BrokerageTotal = DSum("Brokerage", "YourAboveQueryName") 'or do the DSUM on the field and table that has the values.

    Put it inside your email subject or body text. "Body of email with total " & BrokerageTotal & " like you want."

  3. #3
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    The total can be in another query joined here with UNION - get the sort order correct and it will be the last record in the query.

  4. #4
    brownpride is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2016
    Posts
    10
    Bulzie, that worked perfectly! Thanks!

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

Similar Threads

  1. Replies: 1
    Last Post: 01-21-2016, 05:38 PM
  2. Replies: 3
    Last Post: 08-03-2012, 02:37 AM
  3. Getting the Total after a result
    By rjbautista20 in forum Queries
    Replies: 4
    Last Post: 01-22-2012, 01:43 AM
  4. Access query result in excel format
    By Tha-G in forum Queries
    Replies: 1
    Last Post: 01-06-2012, 01:41 PM
  5. Export Query Result to Excel
    By chewbears in forum Access
    Replies: 11
    Last Post: 11-28-2011, 08:31 AM

Tags for this Thread

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