Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grand Total Sum at the end of a query

Status
Not open for further replies.

sportdlockport

Technical User
Apr 13, 2005
38
US
How can I add a grand total sum at the end of a detailed query without using a report. Is this possible in Access?
 
To the best of my knowledge, you'll have to make a summing query which runs off the other query.

-------------------------
Just call me Captain Awesome.
 
Something like
Code:
(Select SomeField, TheNumber From tbl)

UNION ALL

(Select 'Total', SUM(TheNumber) From tbl)
That doesn't guarantee that the "Total" line will be the last line. You would need to use some "Order By" clause to sort it to the end of the list.
 
*I think* that if you have no sorts in the union query, then the results of the 2nd query will just be appended to the first query, i.e. it will be added to the bottom of the report.

but a better option if you're not using the query as a direct display, would be to create a virtual field in your first query, and name it total, and just give it "" as a value, then in your 2nd query, you can put the total in there.

--------------------
Procrastinate Now!
 

Hi there

Just an idea but say you had an [InvoiceDate] field in your query, you could create a field (say [Total]) in your query with the expression
Code:
DSum("[FieldToSum]","Domain", "[Invoice Date] < " & Now())

This would create a running total in the "Total" field for every record as the "Invoice Date" would always be less than Now()

I have not tried this but I don't see why it wouldn't work!

Regards

Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top