Creating a Sum from Report-based queries

ConfusedA

Registered User.
Local time
Today, 05:32
Joined
Jun 15, 2009
Messages
101
I have a system in which i have 2 tables. "tblCost" which has 2 fields (truck and cost/hr) and "tblTruckvalues" which has multiple fields (the important ones here are truck, year, month, job, hours spent). My 2 tables have a relationship along 'truck'

I have a query, 'qryPrice' that has an additional field 'price' which takes the value of cost/hr (which are a set of static values pre-inputted by myself) and determines it's relevance via 'truck' to a set of values inputted in a form, this allows me to multiply "cost/hr" by a user inputted "hours spent". Using another 2 reports I have created search queries based on 'truck', 'year', 'month' and 'job', so that when the user inputs any of the above information a query brings up the truck used, job type and price.

My problem is, I need to be able to calculate the sum of prices for a given set of data.

IE. If I have 5 results for february 2000 on job 'B', I am looking to be able to get a total spent during february 2000 on job 'B', so one entry instead of 5.

How would I go about doing this?
Thanks in advance.
ConfusedA
 
It sounds like you need a totals query. Create a new query based on your query qryPrice. Something like this might work (depending on your table structure)

SELECT [month], [year], job, SUM(price) as sumofprice
FROM qryPrice
GROUP by [month], [year], job

As a tip, I would suggest that you change the names of your fields: month and year. Both words are reserved words in Access and should not be used for table or field names.
 

Users who are viewing this thread

Back
Top Bottom