View Full Version : Adding Values for Multiple departments


slovell
09-21-2007, 05:55 PM
Hi,
This may be a dumb question, but I've got kind of a question about adding values.

I have a subform that contains a department name, and it's waste totals (in Kilograms) for the day, for a particular company. The company information is the main form.

Whenever I start a new department, the totals, and category names start blank (different departments could produce different waste).

I'm trying create a query that gives me the total value for each Category of waste. However, I keep getting all the seperate values returned?? As apposed to a total. For example.

Company A has two departments:
Office and Production.
For Office they had 20 Kg of plastic bottles and Production had 20 Kg of plastic bottles.
I want to be able to total the weight of plastic bottles...it's just not working../
?
Any advice?

ajetrumpet
09-22-2007, 06:58 AM
I'm trying create a query that gives me the total value for each Category of waste. However, I keep getting all the seperate values returned?? As apposed to a total.Trust me, this is not a dumb question...:)

You have to group separate queries by each category with a SUM() column in each. Then you have to UNION the records from each query. This is the way I do it. There may also be some Basic code you can write to shorten this process, but I have not seen or heard of it yet.

I just provided a sample of this to another person. You can look at it HERE (http://www.access-programmers.co.uk/forums/showthread.php?t=135853).