Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sum Unbound Text Boxes

Status
Not open for further replies.

pd2222

Programmer
Oct 15, 2001
14
0
0
GB

I have created a new form, inserted 4 Unbound text boxes. In the 4th box I have inserted in the control source:

=Sum([Text1]+[Text2]+[Text3])

Why won't the above work??? Is it because they are unbound boxes??

Please help!

KG
 
Actually, because you used SUM(), which is used in conjunction with SQL and queries. So yes, it only works on bound controls. Instead do this:

=[Text1]+[Text2]+[Text3]

Jim.

 
Hi,

Cheers for your suggestion which I tried but it didn't actually add them together it just concatenates them. Does this mean I have to admit defeat. All I want to do is have a form which can perform calculations like a calculator!!

Keza
 
I assume it has concatenated them because they are strings? if so convert the strings to numeric.

Private Sub Text4_AfterUpdate()
[SumTextBoxName] = Val([TextBox1]) + Val([TextBox2]) + Val([TextBox3])
End Sub

Place the code in the after update event of the last text box before the 'sum' textbox

David


 
Actually, I would put the code in the After Update of Each textbox unless you want to go through the trouble of clearing or hiding the total until each textbox in turn has been filled.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top