Sum of a row

Dharmesh

Registered User.
Local time
Today, 18:10
Joined
Dec 7, 2006
Messages
25
Hi, does anyone know how to calculate the sum of fields in a cell.

Thanks

Dharmesh
 
You might do a search for : calculate sum on this forum.

Nb. There are no cells in MSAccess.
 
In a calculated field in a query
Code:
MyTotal:[Field1]+[Field2]+[Field3]+.....
 
Neil has the easiest way of doing the sums across a row, but a better question is, why are you storing your data where it would need to be summed in rows instead of columns? That really stinks of Excel-itis. You may want to look at crosstab queries as well, or reconsider your structure.

Of course, if this is just a one-time thing and you aren't summing across rows all over the place, then no need to jump ship and start over. It's just sounding like you're working with Access as if it's Excel, and regardless of the visual similarities between Access' table view and Excel's normal view, they are nothing alike.
 
Just in case, might not the Nz function be suggested?;)
Mais oui, mon brave.
Code:
MyTotal:Nz([Field1])+Nz([Field2])+Nz([Field3])+.....
This ensures that a null value in any field won't make the total throw an error.

Moniker, I've got properly normalised applications where I still need to sum fields in a record but I agree that this can be an indication of design problems.
 
In the query window,
First select those fields you want, ie. field1, field2, ....

Then add a column with formula
MyTotal:Nz([Field1])+Nz([Field2])+Nz([Field3])+.....

This indeed is a calculated field.

It would be better for a beginner to read some tutorials on query first.
Then you might gradually master the power of SQL for using query in the end.
 
Mais oui, mon brave.
Code:
MyTotal:Nz([Field1])+Nz([Field2])+Nz([Field3])+.....
This ensures that a null value in any field won't make the total throw an error.

Moniker, I've got properly normalised applications where I still need to sum fields in a record but I agree that this can be an indication of design problems.
Thank you, I was searching for this solution , and found yours to suit my requirement to a T
 
Thank you, I was searching for this solution , and found yours to suit my requirement to a T
Can you upload a screenshot of the Relationships in your Database?

This would then tell us if the solution provided would suit.
 

Users who are viewing this thread

Back
Top Bottom