Hello,
I have two unbound text boxes 1 and 2 in a form.
I want to get the sum of these two in third text box.
I need vb coding for this.Thanks
Hello,
I have two unbound text boxes 1 and 2 in a form.
I want to get the sum of these two in third text box.
I need vb coding for this.Thanks
No VBA necessary.
In the Control Source property of your 3rd Text Box, simply use an equation like this:
=Val([TextBox1]) + Val([TextBox2])
Thanks.
I know this procedure but I just want to know in VBA.
Pretty straightforward:
You will just need to attach this code to some "event", maybe in the "AfterUpdate" event of the second Text Box, or maybe on the click of a command button.Code:Me.TextBox3 = Me.TextBox1 + Me.TextBox2
I tried this code in after update event of text2 but result is not correct.
I put 2 in text1 and 2 in text2 but instead of result 4 its showing 22 in result.
Did you update the Format property of your Text Boxes to a numeric option, like Fixed?
yes working now.Thanks
I was trying text3.text = text1.text+text2.text
but it was not working.
The ".text" part tells it to return a text value, and not a numeric value. In that case, the "+" works as a "text concatenater" instead of a "numerical adder".
Also, without formatting the text box first, I think the default is to treat it as text also, which is why we want to explicitly format it numerically.
Thanks for explanation.