Storing a calculated control.?? (1 Viewer)

Durien512

Registered User.
Local time
Today, 14:58
Joined
Dec 14, 2005
Messages
61
if i have formula in a text box can that calculation be stored in a table???

example

sales total

sales tax

grand total

where grand total = sales tax+sales total

if the control is bounded to a field in a table once the formula is entered doesnt it loose the connection with the field???

right now when i enter a formula in a control it will no longer store it in the table but it will only show the result in the actual form..???
 

RuralGuy

AWF VIP
Local time
Today, 15:58
Joined
Jul 2, 2005
Messages
13,826
In order to store the value calculated in your TextBox you will need to add some code to the Form's BeforeUpdate event. You already know that it is bad practice to store calculated values unless there is some historical reason, as you have, where the sales tax rate might change. In the BeforeUpdate event of the form put something like:
Me![TotalSalesField] = Me!txtTotalSaleCalcControl

Using your control and field names of course.
 

reclusivemonkey

Registered User.
Local time
Today, 22:58
Joined
Oct 5, 2004
Messages
749
The calculated field is only shown in the form. You will need to use an update query to add the value to the table.
 

neileg

AWF VIP
Local time
Today, 22:58
Joined
Dec 4, 2002
Messages
5,975
Just to reiterate:

You don't store things that can be calculated from other stored data. If, as RuralGuy suggests, the tax rate may change, then it is legitimate to store the amount of the tax calculated. However, since grand total will always be sales total plus tax total, you should not save that value.
 

Users who are viewing this thread

Top Bottom