Sum question

D

Dimitris

Hello.

In a table I have 4 numeric fields. N1 N2 N3 N4 and I also have a field
named S14.
What I need is to add the fields N1 N2 N3 N4 and the result written in the
S14. For each record I mean. So S14 is the sum of the 4 previous fields of
each record.

Can you help me?
Thanks
Dimitris
 
S

scubadiver

You don't need a field especially for the total (you shouldn't be storing
totals in tables anyway).

It can be done in the query as an expression

total: [N1]+[N2]+[N3]+[N4]
 
D

Dimitris

Thank you,

In my case I need to store.
Can you help me?

Dimitris


scubadiver said:
You don't need a field especially for the total (you shouldn't be storing
totals in tables anyway).

It can be done in the query as an expression

total: [N1]+[N2]+[N3]+[N4]



--
"Loose Change 2nd Edition" has been seen by almost 7 million people on
Google video


Dimitris said:
Hello.

In a table I have 4 numeric fields. N1 N2 N3 N4 and I also have a field
named S14.
What I need is to add the fields N1 N2 N3 N4 and the result written in the
S14. For each record I mean. So S14 is the sum of the 4 previous fields of
each record.

Can you help me?
Thanks
Dimitris
 
S

scubadiver

In the "after update" event for N1...N4 put the following

SN14 = [N1]+[N2]+[N3]+[N4]

--
"Loose Change 2nd Edition" has been seen by almost 7 million people on
Google video


Dimitris said:
Thank you,

In my case I need to store.
Can you help me?

Dimitris


scubadiver said:
You don't need a field especially for the total (you shouldn't be storing
totals in tables anyway).

It can be done in the query as an expression

total: [N1]+[N2]+[N3]+[N4]



--
"Loose Change 2nd Edition" has been seen by almost 7 million people on
Google video


Dimitris said:
Hello.

In a table I have 4 numeric fields. N1 N2 N3 N4 and I also have a field
named S14.
What I need is to add the fields N1 N2 N3 N4 and the result written in the
S14. For each record I mean. So S14 is the sum of the 4 previous fields of
each record.

Can you help me?
Thanks
Dimitris
 
D

Dimitris

Thank you for your answer.
The table already has data in the fields N1 N2 N3 N4 and S14 in which I want
the sums is empty. How can I get it to have the sum of each record entered
there? I'm afraid I didn't understand what to do.

Dimitris

scubadiver said:
In the "after update" event for N1...N4 put the following

SN14 = [N1]+[N2]+[N3]+[N4]

--
"Loose Change 2nd Edition" has been seen by almost 7 million people on
Google video


Dimitris said:
Thank you,

In my case I need to store.
Can you help me?

Dimitris


scubadiver said:
You don't need a field especially for the total (you shouldn't be storing
totals in tables anyway).

It can be done in the query as an expression

total: [N1]+[N2]+[N3]+[N4]



--
"Loose Change 2nd Edition" has been seen by almost 7 million people on
Google video


:

Hello.

In a table I have 4 numeric fields. N1 N2 N3 N4 and I also have a field
named S14.
What I need is to add the fields N1 N2 N3 N4 and the result written in the
S14. For each record I mean. So S14 is the sum of the 4 previous fields of
each record.

Can you help me?
Thanks
Dimitris
 
J

John W. Vinson

The table already has data in the fields N1 N2 N3 N4 and S14 in which I want
the sums is empty. How can I get it to have the sum of each record entered
there? I'm afraid I didn't understand what to do.

Storing derived data such as this in your table accomplishes
three things: it wastes disk space; it wastes time (almost
any calculation will be MUCH faster than a disk fetch); and
most importantly, it risks data corruption. If one of the
underlying fields is subsequently edited, you will have data
in your table WHICH IS WRONG, and no automatic way to detect
that fact.

Just redo the calculation whenever you need it, either as a
calculated field in a Query or just as you're now doing it -
in the control source of a Form or a Report textbox.

John W. Vinson [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