I have a query which returns a column of prices. How do I, by query or otherwise, perform a calculation that would return the sum of the prices? I intend to place this value in a combobox in a report.
Cheers
Rob
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » summing a field (A97)
Rob,
In a report, it is easy to sum values. Place a text box in the report footer section with Control Source
=Sum([fieldname])
Replace fieldname by the name of the column you want to sum.
If you group your report on some kind of category, you can calculate the sum for each group by placing such a text box in the group footer section.
Note: a combo box is not much use in a report, for the user can’t interact with it – in fact, the dropdown arrow of a combo box is not even displayed in a report.
Hi Hans!
I have the same problem as Rob. However, the text box on my report shows an error. I am getting my price from a calculation in a query called qrymaketableinvoice. This returns the correct data (a list of 3 prices). In the report footer I have a text box whose control source is set to =Sum( [qrymaketableinvoice]![Expr1]). Please would you tell me where I am going wrong?
Thanks,
Katie
Hello Katie,
Welcome to the Lounge!
The name qryMakeTableInvoice makes me think it might be an action query that creates a table. You can’t use action queries as record source of a form or report.
If it is a selection query, is it the record source of the report? If so, you can use =Sum([Expr1]) – no need to include the query name. Also, you would have to use a dot . instead of a bang ! between query name and field name.
If the query is *not* the record source, you may need a DSum. Let us know if you need this, we will help you with it.
Thank you Hans for your help! The report is generated by a select query and one of the fields is named “Total”. This refers to the price for a particular order. The report lists a number of orders. The report detail is accurate showing three orders with their three different totals. The control source of the text box in the report footer is set to =sum(Total), but I still keep getting an error. I hope this information is more useful.
Thanks,
Katie,
There may be confusion over field names vs control names. General advice is to make control names different from the fields they are bound to; for instance a text box with control source Total would be named txtTotal. Unfortunately, Microsoft doesn’t adhere to this. If you have another control named Total on the report, =Sum(Total) would cause an error, so check that. The Formatting (Form/Report) toolbar has a dropdown list with all controls.
Hans,
I think my brain has finally ceased up. I have been trying many expressions in the text box in the report footer to return sum of a column generated from a query. I have also tried a DSum like this in the control source:
=DSum(“Subtotal”,”qryOrders”)
My query (qryOrders) pulls in fields from 3 tables, 2 of which are “Price” and “Quantity”. A calculated field, “Subtotal” is the product of the 2 fields and it works perfectly. This query is the record source for a report called rptInvoice. This too works fine. The problem arises when I try to sum the values in the Subtotal field of the query using a textbox in the report footer. I just get an error each time. I’m sure this ought to be quite straightforward but I’m making heavy weather of it.
I hope I’ve not overelaborated but I thought the extra info may suggest to you the nature of the problem and/or a solution.
Many thanks
Rob
Hi Pat
That’s what I am finding frustrating. There are no controls called Subtotal. Subtotal is the name of a field in the underlying query (qryOrders) from which the report is built. The report lists correctly the individual orders which include the Subtotal field.
Still, it’s all part of the learning curve.
Further advise would be appreciated.
Rob
Pat
No joy, I’m afraid.
I’ll delete both the query and report and reconstruct them anew. The db would be too big even when pared down.
WRT Alf E, I found a Christmassy image, but my graphic manipulating skills are even worse than my access ones.
Seasonal greetings to you and thanks for your help.
Cheers
Rob
Pat
I’m looking at the report in design mode now and I see I have the text box in the page footer instead of the Report footer. However, on moving it there, the report changes to portrait from landscape. Once a report has been created, how do you change orientation?
Thanks for sorting the other problem out. I cannot believe I’m so unobservant.
BTW, Alf’s back.
Cheers Rob
Pat
You are a Trojan!
Begging your indulgence, I have one more question which would make sleep easier over Chrimble.
After a period of time, I would want to assess the popularity of Dishes sold to improve the service provided to customers. The table, tblOrders stores the Dishes ordered over a period of time. What would be the query that returned the sum of each individual dish from tblOrders. Would a Crosstab be appropriate in this case?
Cheers
Rob
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.
Notifications