Pass a value from a text box to a field in a table

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to figure out something that has been troubling me for a while.

I have a text box in a form that calculates a value and I need it to write
it to table. The calculation is correct but the value does not get entered
into the table. How do I accomplish this?
 
Tom

A general consideration in relational design is that there is rarely a need
to store calculated values. In addition to not needing to use extra storage
space, and the slower processing to retrieve from storage, you end up
needing to create synchronization routines to ensure that the stored value
and its underlying terms and factors (what you use to calculate with) still
compute to the same value.

There are occasional legitimate business needs to store calculated value.
If you'll post back with more specifics about what you are trying to do, the
'group readers may be able to offer alternatives.
 
What I'm trying to do is make a form for Purchase Orders. The user enters
the amount of the purchase order and the value for the tax value is
calculated in the form. I would like the calculated tax value entered in the
table.
 
Tom

You have a situation in which the tax amount can be calculated. It still
isn't necessary to save the calculated tax...

I can see a practical (i.e., quick/dirty) use of storing the tax value, but
are you prepared to bite the bullet and make sure that you've also ensured
synchronization? What should happen if an error was made in entering the
Purchase Order, and the amount is changed ...? I expect you'll want the tax
value recalculated. What if someone decides to modify the tax value ...
will the Purchase Order amount be adjusted?

Another potential solution, even if the the tax percentage changes over
time, would be to set up a TaxRate table that holds the tax rate
(percentage) between a start and end date. Then, any time the tax rate
changes, create a new row in the TaxRate table, with a begin date. EndDate
the old rate. You can still calculate a tax value, on the fly, by using the
TaxRate row valid during the time period when the Purchase Order was dated.

This, too, will require some work, so you need to decide which scenario is
more likely. Are you more likely to need to handle variable tax rates or
the possibility that amounts will be changed?

If you decide to store the tax value in your table, you'll need a field in
the table to hold it, and you'll need to bind a control on your form to that
field. That way, when the form "calculates" the tax value and is
subsequently saved, the tax value will be saved in its tax value field.
 
Back
Top