PDA

View Full Version : sum fields, add column and put total in



austenr
11-13-2006, 08:58 AM
I have a table where I need to sum three fields on the same row and place the result in a new column called total. How would you do this if you were in design view not VBA?

OBP
11-13-2006, 09:49 AM
austenr, it is generally accepted that you do not "Store" calculated fields in tables as it is just a waste of disc space. Unless you have a very good reason for storing it, the normal method is to just "present the data in a query, form or report.
Which is why there isn't a mechanism to do the calculation in a table.
You can do the calculation using a query or VBA to store the result in a field if you want.

austenr
11-13-2006, 10:07 AM
Can you post an example of calculating using a wuery and storing the result in a field. That is what I am after anyway. Thanks

Norie
11-13-2006, 10:26 AM
Can't you just use an expression like this?


TotalField:[Field1]+[Field2]+[Field3]

OBP
11-13-2006, 11:30 AM
austenr, did you look at my previous answers to this post

http://vbaexpress.com/forum/showthread.php?t=10095

Norie's Column Heading Function is exactly what you use for displaying the the calculation, but not putting the value in the table. I think that will have to be done with an update query. You will have to decide how and when you are going to run the query. Do you run it each time you adda record and filter the query to the current record?

austenr
11-13-2006, 11:44 AM
OB,

Nories suggestion will work. I am trying to determine the differences between two months of data. One month has the calculated field so that is not a problem. The other month, I have to add three fields to get that same number from the other month. Hence my delima, do I just cut and paste to Excel or try to do what Norie and you suggested.

OBP
11-13-2006, 12:29 PM
If you just need the number for a report etc then a query will do it for you, any chance of posting something for us to check out?