Problem Adding Multiple Fields in Form to New Text Box

M

Maurita

Hi, hope someone can help me with a problem that I can't seem to work
out. I have four fields on my form that are set to currency, they are
Federal Tax, State Tax, SSMedicare, and CountyTax, which work fine. I
have another text box which I am having trouble with, which I am trying
to total all four amounts to and have it saved in the table. If I add
Field1 and Field2, I get a total. But, If I try to add Field3, I get
nothing. I have searched this forum and tried different ways, but no
total after two amounts will work. The following code for two amounts
work, so I don't understand why I can't add more than two fields.
=[StateTax]+[CountyTax]

Please let me know what I am missing.

Thank you so very much for all your help.

Maurita Searcy
 
A

Allen Browne

If any one of the fields is Null (blank box), the total will be Null.
Use Nz() to indicate Access should use zero for null, i.e.:
=Nz([Federal Tax],0) + Nz([State Tax],0) + Nz([SSMedicare],0) +
Nz([CountyTax],0)

You do *not* want to store this total in your table. Causes way too many
unnecessary headaches keeping it up to date, when you can use an expression
like that in a query and it can never be wrong. For more info on that, see:
Calculated fields
at:
http://allenbrowne.com/casu-14.html
 
K

Klatuu

If any of the four fields contains a Null, adding them together will return
Null. You could try wrapping all the numbers in the Nz function to eliminate
the problem.
Total = Nz(Field1,0) + Nz(Field2,0) + Nz(Field3,0) + Nz(Field4,0)

However, the thing you are actually doing wrong is stroring a calculated
value in a table. That is one of the basic rules of relational database
design. As long as you have all the data to perform the calculation, storing
a calculated value wastes time and disk space and runs a strong possibility
of becoming incorrect. The correct technique would be to perform the
calculation each time you need to present the result to a user on a form or
in a report.
 
M

missinglinq via AccessMonster.com

Doesn't seem to make sense. You need to post all of the code where you're
trying to add the four fields together. BTW, you really shouldn't be storing
the calculated result in the table.
Hi, hope someone can help me with a problem that I can't seem to work
out. I have four fields on my form that are set to currency, they are
Federal Tax, State Tax, SSMedicare, and CountyTax, which work fine. I
have another text box which I am having trouble with, which I am trying
to total all four amounts to and have it saved in the table. If I add
Field1 and Field2, I get a total. But, If I try to add Field3, I get
nothing. I have searched this forum and tried different ways, but no
total after two amounts will work. The following code for two amounts
work, so I don't understand why I can't add more than two fields.
=[StateTax]+[CountyTax]

Please let me know what I am missing.

Thank you so very much for all your help.

Maurita Searcy
 
M

Maurita

Thank you so very much for all your help. The code worked great and I
appreciate the assistance. As to saving the total in the table, I
totally understand about not saving this amount and thank you for
advising me about this matter. I now understand why I was having
problems; the FederalTax field was empty.

Maurita Searcy
Doesn't seem to make sense. You need to post all of the code where you're
trying to add the four fields together. BTW, you really shouldn't be storing
the calculated result in the table.
Hi, hope someone can help me with a problem that I can't seem to work
out. I have four fields on my form that are set to currency, they are
Federal Tax, State Tax, SSMedicare, and CountyTax, which work fine. I
have another text box which I am having trouble with, which I am trying
to total all four amounts to and have it saved in the table. If I add
Field1 and Field2, I get a total. But, If I try to add Field3, I get
nothing. I have searched this forum and tried different ways, but no
total after two amounts will work. The following code for two amounts
work, so I don't understand why I can't add more than two fields.
=[StateTax]+[CountyTax]

Please let me know what I am missing.

Thank you so very much for all your help.

Maurita Searcy
 

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