How to set value of the bound textbox??

thepooh

Registered User.
Local time
Tomorrow, 07:36
Joined
Jun 2, 2003
Messages
11
I have a textbox called txtSum, which is bound to the field Sum. Therefore, in its property, the control source would be Sum. The value for this textbox is supposed to be the total of two other textbox controls, say txtNum1 and txtNum2. And after user enter the value for these 2 boxes, the txtSum is supposed to show the sum. But how do I do that? I tried to write under

Private Sub txtNum2_afterupdate()
txtSum.Text = txtNum1.Text + txtNum2.Text
End Sub

But i get this error:
You can't reference a property or method for a control unless the control has the focus.
 
You can only use the .text property if the control has focus. Drop it and try:

txtSum = txtNum1 + txtNum2

The default is .value, which is what you want anyway.

By the way, I would change the name of the field named "sum". Since there is a function called Sum(), Access will get confused sooner or later. Here's a list of reserved words:

http://support.microsoft.com/default.aspx?scid=kb;en-us;209187
 
Thanks, pbaldy
 
You shouldn't store this value at all, it can be calculated at any time
 

Users who are viewing this thread

Back
Top Bottom