Summing Text Boxes

H

Haji

Hi,

I have a subform with four text boxes which are based on
fields from four different tables. The subform is tied to
the main form through a customer number field which is
invisible on the subform. What I want to do is to create
a fifth text box on the subform that sums the other four
text boxes on the subform. Can anyone help with this?

Thanks,

Chuck
 
R

Rick Brandt

Haji said:
Hi,

I have a subform with four text boxes which are based on
fields from four different tables. The subform is tied to
the main form through a customer number field which is
invisible on the subform. What I want to do is to create
a fifth text box on the subform that sums the other four
text boxes on the subform. Can anyone help with this?

=Nz(Control1,0) + Nz(Control2,0) + Nz(Control3,0) + Nz(Control4),0)

The Nz()s are in case any of the controls contain Null. If that will never
be the case you can just use...

=Control1 + Control2 + Control3 + Control4
 
H

Haji

Rick,

Thanks for you help with this. I have entered the
following into the control source on my new text box.
The values (i.e. 2003_Q1_Sales) are the names of my text
boxes that I want to sum.

=Nz(2003_Q1_Sales,0) + Nz(2003_Q2_Sales,0) + Nz
(2003_Q3_Sales,0) + Nz(2003_Q4_Sales,0)


I keep getting a message that says "The expression you
entered contains invalid syntax. You omitted an operand
or operator or you entered an invalid comma or character
or you entered text without surrounding it with quotation
marks".

Any idea what I am doing wrong.

Thanks

Haji
 
R

Rick Brandt

Haji said:
Rick,

Thanks for you help with this. I have entered the
following into the control source on my new text box.
The values (i.e. 2003_Q1_Sales) are the names of my text
boxes that I want to sum.

=Nz(2003_Q1_Sales,0) + Nz(2003_Q2_Sales,0) + Nz
(2003_Q3_Sales,0) + Nz(2003_Q4_Sales,0)


I keep getting a message that says "The expression you
entered contains invalid syntax. You omitted an operand
or operator or you entered an invalid comma or character
or you entered text without surrounding it with quotation
marks".

Any idea what I am doing wrong.

I don't see a problem with your syntax. You could try putting square
brackets around the TextBox names

=Nz([2003_Q1_Sales],0) + Nz([2003_Q2_Sales],0)
+ Nz([2003_Q3_Sales],0) + Nz([2003_Q4_Sales],0)
 

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