How to push back a value from a control to a field?

  • Thread starter Thread starter hkgary33 via AccessMonster.com
  • Start date Start date
H

hkgary33 via AccessMonster.com

Dear all,
In my form frmVIEW, it allows the user to enter and update files’ fields.
Each file have 11 numeric fields, the first 10 numeric fields are for user to
input and the last numeric field is for automatically summing the totals.
I’ve successfully display this sum in the form, (by using a formula to sum
those 10 fields in the Control Source). However, this sum field only appears
in the form, but it can’t “push” the sum value back to the field. How can I
write in VBA programming so that the sum can successfully “push” in to the
field? (I really need to use an additional field to store the sum in order to
facilitate my chart plotting in later stages)

Thanks so much for your help!
Gary
 
Gary,
How can I write in VBA programming so that the sum
can successfully "push" in to the field?

Actually... you don't...
You should never save the results of a calculation, as long as you captured all the
elements that led to that calculation in your table. (the 10 nums)
That calculated value can always be re-derived in any subsequent form, query, or
report... so no need to save it.

If you must save it, then create a new field in your table called (ex.) TenTotal.
Add that field to the query behind the report.
Remove the calculation from the field on the form and set the ControlSource to
TenTotal.
(here's where you will see the problem with saving calculated values...)
Now, on the AfterUpdate event of EACH of your ten numbers, place this code...
TenTotal = NZ(Num1) + NZ(Num2)... through ... NZ(Num9) + NZ(Num10)

Any time any one of the ten numbers is updated, the re-calculated value will be saved
in the TenTotal field.

--
hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions
There are 10 types of people in the world.
Those who understand binary, and those who don't.
 
hkgary33 said:
In my form frmVIEW, it allows the user to enter and update files’ fields.
Each file have 11 numeric fields, the first 10 numeric fields are for user to
input and the last numeric field is for automatically summing the totals.
I’ve successfully display this sum in the form, (by using a formula to sum
those 10 fields in the Control Source). However, this sum field only appears
in the form, but it can’t “push” the sum value back to the field. How can I
write in VBA programming so that the sum can successfully “push” in to the
field? (I really need to use an additional field to store the sum in order to
facilitate my chart plotting in later stages)


You really should not do that. If your chart needs the
total, then it should be based on a query the calculates the
total (essentially the same way the text box on the form
calculates it).
 
Back
Top