calculation in text box

  • Thread starter Thread starter Roger
  • Start date Start date
R

Roger

I have an unbound text box that makes a calculation and I want to save it as
part of the record in the table. Was easy in 97 but now in 2002 and SQL
server wont work the same way. Any help would be appreciated.

Roger
 
Roger,
"Usually" calculations aren't saved in a table. The "elements" of the
calculation are saved, and the calculation is performed "on the fly" in
subsequent forms/queries/reports...
However, there are legitimate reasons to save the results of a
calculation. An example would be
Price*Qty = LineTotal
where the Price may change in the future and you want that result saved in
the "historical" record.
Anyhoo... using this example, add a field to your table called LineTotal
to your table, and on the AfterUpdate event of BOTH Price and Qty...
[LineTotal] = [Price] * [Qty]
On your form, you can keep the unbound field with =Price*Qty to display
(only) the calculation or use the new field Line Total instead.
hth
Al Camp
 
Thanks for that AL. I will give it a try but the calculation is a bit more
complicated than a simple multiplication so I hope it will work in this
manner. I s there a simple piece of code that will take the result of an
unbound text box and add to the record??Roger


AlCamp said:
Roger,
"Usually" calculations aren't saved in a table. The "elements" of the
calculation are saved, and the calculation is performed "on the fly" in
subsequent forms/queries/reports...
However, there are legitimate reasons to save the results of a
calculation. An example would be
Price*Qty = LineTotal
where the Price may change in the future and you want that result saved in
the "historical" record.
Anyhoo... using this example, add a field to your table called LineTotal
to your table, and on the AfterUpdate event of BOTH Price and Qty...
[LineTotal] = [Price] * [Qty]
On your form, you can keep the unbound field with =Price*Qty to display
(only) the calculation or use the new field Line Total instead.
hth
Al Camp

Roger said:
I have an unbound text box that makes a calculation and I want to save
it
as
part of the record in the table. Was easy in 97 but now in 2002 and SQL
server wont work the same way. Any help would be appreciated.

Roger
 
Roger,
Yes it will. My simple calculation was just a representation, but the
concept is the same, no matter how complicated the calculation is.
Remember that on the AfterUpdate event of each element in your
calculation, you'll have to "update" the field that holds the calculation
result. (lets say it's called MyCalc)
manner. I s there a simple piece of code that will take the result of an
unbound text box and add to the record??

On each "element" AfterUpdate you could code it this way...
Refresh
MyUnboundCalcFieldOnTheForm = MyCalc

Either method will work.
hth
Al Camp


Roger said:
Thanks for that AL. I will give it a try but the calculation is a bit more
complicated than a simple multiplication so I hope it will work in this
manner. I s there a simple piece of code that will take the result of an
unbound text box and add to the record??Roger


AlCamp said:
Roger,
"Usually" calculations aren't saved in a table. The "elements" of the
calculation are saved, and the calculation is performed "on the fly" in
subsequent forms/queries/reports...
However, there are legitimate reasons to save the results of a
calculation. An example would be
Price*Qty = LineTotal
where the Price may change in the future and you want that result saved in
the "historical" record.
Anyhoo... using this example, add a field to your table called LineTotal
to your table, and on the AfterUpdate event of BOTH Price and Qty...
[LineTotal] = [Price] * [Qty]
On your form, you can keep the unbound field with =Price*Qty to display
(only) the calculation or use the new field Line Total instead.
hth
Al Camp

Roger said:
I have an unbound text box that makes a calculation and I want to save
it
as
part of the record in the table. Was easy in 97 but now in 2002 and SQL
server wont work the same way. Any help would be appreciated.

Roger
 
Thanks alot Al will give it a try

kindest regards
Roger


AlCamp said:
Roger,
Yes it will. My simple calculation was just a representation, but the
concept is the same, no matter how complicated the calculation is.
Remember that on the AfterUpdate event of each element in your
calculation, you'll have to "update" the field that holds the calculation
result. (lets say it's called MyCalc)
manner. I s there a simple piece of code that will take the result of an
unbound text box and add to the record??

On each "element" AfterUpdate you could code it this way...
Refresh
MyUnboundCalcFieldOnTheForm = MyCalc

Either method will work.
hth
Al Camp


Roger said:
Thanks for that AL. I will give it a try but the calculation is a bit more
complicated than a simple multiplication so I hope it will work in this
manner. I s there a simple piece of code that will take the result of an
unbound text box and add to the record??Roger
saved
in
the "historical" record.
Anyhoo... using this example, add a field to your table called LineTotal
to your table, and on the AfterUpdate event of BOTH Price and Qty...
[LineTotal] = [Price] * [Qty]
On your form, you can keep the unbound field with =Price*Qty to display
(only) the calculation or use the new field Line Total instead.
hth
Al Camp

I have an unbound text box that makes a calculation and I want to
save
it
as
part of the record in the table. Was easy in 97 but now in 2002 and SQL
server wont work the same way. Any help would be appreciated.

Roger
 
Back
Top