Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 10th, 2006, 08:11 AM
Authorized User
 
Join Date: Apr 2006
Posts: 46
Thanks: 0
Thanked 1 Time in 1 Post
Default Sum two different fields

Hi, again
I have two fields with numbers and I want to have the sum of them in a third field
Please can you tell me how can I do it!

The Following User Says Thank You to Vision G For This Useful Post:
 
Old May 10th, 2006, 08:30 AM
Authorized User
 
Join Date: Apr 2006
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

put both fields into your query then create an expression, something like this:

summedfield:[column1]+[column2]

Hope that helps

 
Old May 10th, 2006, 08:50 AM
Authorized User
 
Join Date: Apr 2006
Posts: 46
Thanks: 0
Thanked 1 Time in 1 Post
Default

Where should I write this
summedfield:[column1]+[column2]
Thank you

 
Old May 10th, 2006, 08:22 PM
Authorized User
 
Join Date: Apr 2006
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Just put the formula in just like you would put in a new field into a query


 
Old May 15th, 2006, 03:26 AM
Authorized User
 
Join Date: Apr 2006
Posts: 46
Thanks: 0
Thanked 1 Time in 1 Post
Default

I m sorry it isn't what I want.
To be more specific!
There is a query like:
Name Count1 Count2

John 20 10
Nick 30 25

but these numbers came as sum e.g. John 20 (18+5+7), 10 (5+5)
now I want a third field in the query with these three fields and one more with the total of every row 20+10=30
                       30+25=65

I think this would help!
Thank you

 
Old May 15th, 2006, 05:38 AM
Authorized User
 
Join Date: May 2006
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Ashfaque
Default

Put into the query as follows:

Sum(Count1+Count2) as Count3

HTH
Ashfaque

 
Old May 15th, 2006, 05:51 AM
Authorized User
 
Join Date: Apr 2006
Posts: 46
Thanks: 0
Thanked 1 Time in 1 Post
Default

Thank you Ashfaque that's it!
Be well!!!

Vision G

 
Old May 15th, 2006, 09:07 AM
Authorized User
 
Join Date: Apr 2006
Posts: 46
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi again,
When Column 1 is null and column 2 with a number it doesn' t show me the third column (sum}!
what should I do!!!

 
Old May 16th, 2006, 05:07 AM
Authorized User
 
Join Date: May 2006
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Ashfaque
Default

If you need it in query then it would be something like this: (Tested already)

SELECT Table1.Col1, Table1.Col2, IIf(IsNull(Table1.Col1),0,Table1.Col1) AS x1, IIf(IsNull(Table1.Col2),0,Table1.Col2) AS x2, ([x1]+[x2]) AS Col3
FROM Table1;

This will give you an idea.

Note that your data type field of the original table should be numeric

HTH
Ashfaque





Similar Threads
Thread Thread Starter Forum Replies Last Post
Sum of the fields in the report footer sudagnr Crystal Reports 0 April 3rd, 2008 07:07 AM
how to sum in for-each Gjella XSLT 1 October 2nd, 2006 08:48 AM
Help: Running Sum (or Cumulative Sum) timdasa VB Databases Basics 1 August 22nd, 2006 03:12 PM
Sum Jonas Access VBA 1 August 4th, 2006 12:41 PM
Using Forum fields select fields on the fly hellosureshkumar Crystal Reports 0 December 17th, 2004 08:20 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.