How do i sum up all values in a field given some criteria?

kwokv616

Registered User.
Local time
Today, 05:33
Joined
Nov 10, 2008
Messages
46
I have a table with a number of fields and many records and I need to sum up the values of cells of a column that meets certain criteria (eg. column1=column2, iif(column3=0)) and then sum it up to become a value under a new column in a new table.
I need to make a number of these new summation values to make up a new table of two rows and a number of columns (depending on the number of summed values i need)
How do i do this with VBA code? or any other method (but i need this to be run when one clicks on a button on a form)
Thank you!!
 
You are not making any sense.
Please rephrase the question and slip in words like Excel, Access, Records, Columns and version numbers where needed.

Thanks!
 
Sorry =P
let me rephrase this.

I have a table1 in access db that has several columns and many rows.

I need to produce another table2 using the data in this table1.

I need to sum up all the cell values of a column "cost" in table1 -> to make one new value.

This value, i need it to appear in table2 under the column name "total_cost".

How do i do this?

thank you so much!!
 
You do not need a table2 what you want is a new query that sums the value from table 1
 
As DCrake mentioned, you don't need a new table. Just a query like this:
Code:
select sum(cost) as total_cost from table1
If you name this query table2, there's your solution.

I wouldn't do that however.

Enjoy!
 
Thank you so much i get it now!!!
but if i want this to be done automatically when i click on a button on a form, how do i do it?
 
Stating the obvious what do you want to do when you click the button? The query will always be correct.
 

Users who are viewing this thread

Back
Top Bottom