Adding two fields to Equal one Field

  • Thread starter LisaJohn via AccessMonster.com
  • Start date
L

LisaJohn via AccessMonster.com

Hi

I've already created a query based on a table and I am at a point where I
would like to add two fields together and have the data from that equation in
another field on the same table. I have already completed the calculation but
the two numbers that I added together are sitting side by side in the new
field.

How can I get the numbers to finally compute within this new field and to not
sit side by side?

It currently looks like this:

Field 1 Field 2 Field3
200 200 200 200

Any help would be great!

I am a newbie. Thanks in advance!
 
D

Duane Hookom

Generally, you don't want to store a value like this that can be calculated
as needed. It's against basic rules.

If your two fields are numeric data type, all you whould have to do is
create a new column with the expression:
Field3: [Field 1] + [Field 2]
If this doesn't work as expected maybe one or both of your original fields
aren't numeric.
 
T

Tom van Stiphout

On Mon, 12 Oct 2009 12:39:12 GMT, "LisaJohn via AccessMonster.com"

You're making a mistake. Calculated values don't belong in a
relational database, but rather in a query. Assuming Field1 and Field2
are numeric columns, your query would be:
select Field1, Field2, TheSum: Field1 + Field2
from myTable
The huge benefit of this approach is that you don't have to carefully
keep the three values in sync. You simply calculate when needed.

-Tom.
Microsoft Access MVP
 
A

Armen Stein

Hi Duane and Tom,

I think the OP means that they are trying to add a calculated field to
a *query*, not a table. If so, they're not making a mistake.

Hi LisaJohn,

Follow the previous directions for adding your numbers together in the
query. It looks like your fields are defined as text instead of
numbers, that's why they are concatenating instead of adding.

Armen Stein
Microsoft Access MVP
www.JStreetTech.com
 
D

Duane Hookom

I assumed
"...and have the data from that equation in another field on the same table"
meant what it said.

Of course we all know the meaning of "assume" ;-)
 
T

TedMi

I too, in reading OP's post, thought he meant the sum field is in a query.
To a newbie, the columns in the output of a query look very much like fields
in a table!
Evidently, the values are text, and are being concatenated instea of added.
-TedMi
 
T

Tom van Stiphout

On Mon, 12 Oct 2009 08:34:01 -0700, Duane Hookom

Since we're all assuming here, I took the OP's word for it when (s)he
wrote: "the two numbers that I added together".
In my reply I underscored that point: "Assuming Field1 and Field2
are numeric columns".
But you have a good point: if none of the above is true, the OP is
likely concatenating strings.

-Tom.
Microsoft Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top