Connecting Tech Pros Worldwide Forums | Help | Site Map

how do i sum up the values of a field?

Newbie
 
Join Date: Nov 2008
Posts: 13
#1: Nov 25 '08
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!!

Expert
 
Join Date: Jan 2008
Posts: 365
#2: Nov 25 '08

re: how do i sum up the values of a field?


Hello again Kwokv616,

Once again, what you're describing is what can all be done in a query.

Once thing to keep in mind, with MS Access, it is very BAD programming practice to sum values from one table and added them to another table for review.. The problem inevitably is that some of the data will change, and you will have to go back and re-sum all the value again.

The way that we get around this is to simply base a form on a query that will display the calculated information the way that you would like. Then you can start to base forms and reports on this query.

So the query would look something like this:

Expand|Select|Wrap|Line Numbers
  1. SELECT Sum(Column1) FROM TableName WHERE Column1 = Column2 or Column3 = 0
  2.  
This doesn't require any VBA coding at all. this can be done in the query builder that comes with MS Access.

If you need more detailed help, let me know, and I would be more than happy to help.

Joe P.
Newbie
 
Join Date: Nov 2008
Posts: 13
#3: Nov 25 '08

re: how do i sum up the values of a field?


My required endproduct is:
A summed value in another table under a new column

Which means after summing up the values using your given SQL to give one new value, i would need it to display this new value under another column name.

How do I do this?

Thanks alot =)
Reply