By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,493 Members | 1,176 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,493 IT Pros & Developers. It's quick & easy.

how do i sum up the values of a field?

P: 13
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!!
Nov 25 '08 #1
Share this Question
Share on Google+
2 Replies


Expert 100+
P: 374
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.
Nov 25 '08 #2

P: 13
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 =)
Nov 25 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.