How to put the calculated data from a textbox on a form into a field on table?

ariansman

Registered User.
Local time
Today, 08:06
Joined
Apr 3, 2012
Messages
157
I have added an unbound textbox namely “textbox A” on a form. I typed an expression in the “Control Source” property box, for example [textboxB]*2. Now textboxA shows my desired calculation. I want this calculation to be inserted on table “turn over” , field “my sum”. but this does not happen when I click on the “save record” button that I had already made. How can i solve this problem?
Thank your
 
Please show us the code behind he Click event of the button.
Also, you would not normally store the result of a calculation in a table - you would perform a query to do the calculation when needed.
 
First, just to re-iterate jdraw's comment, it is very, very unusual to have a Calculated Field that needs or should be stored! You simply re-calculate when needed. Every thing else aside, this type of calculation will be faster than retrieving the data from your hard drive.

Having said that, if you simply have to do this, you need to move your calculation elsewhere, usually into the AfterUpdate event of the one or more Controls whose data is used in the Calculation:
Code:
Private Sub TextboxB_AfterUpdate()
  If Nz(Me.TextboxB, "") <> "" Then
   Me.TextboxA = Me.TextboxB * 2
  End If
End Sub
Now you're free to go to the Control Source of TextboxA and assign the Field in the Table where you want the Calculation stored.

Linq ;0)>
 

Users who are viewing this thread

Back
Top Bottom