Copy calculated value to a field

J

jenni_p

Hello -
I have a form and subform set up. There is an unbound
calculated field on the subform ContractLbs which
calculates the weight of each detail item in the
subform. I have a button that I need the user to be able
to click in the subform to "confirm" their order. In the
on click event, I need the amount in ContractLbs to be
copied to the field Contractual_Lbs which is a field
bound to the table.

Currently have have this set up in the on click event,
[Contractual_Lbs] = [ContractLbs]

The problem is that it only works for the one detail
record that you are on and I need it to appply the
command for all records in the subform at once.

Any help would be appreciated.
Thank you,
Jenni
 
R

Roger Carlson

Consider NOT saving the value to a table. If you can calculate it in the
form, you can calculate it in any query or report and there is no reason to
save it.

In fact, by normalization theory, you shouldn't (under most circumstances)
store calculated values. It introduces data integrity issues. What happens
if one of the values that makes up the calculation changes? If the
calculated value is stored, it does not get automatically recalculated and
is now incorrect. Calculating stuff is what the computer does best. Just
let it do it for you whenever you need that value.
 
S

solex

Jenni,

I believe that you will need to update all of the values with a sql
statement.

For instance:

UPDATE YourSubFormTableName SET Contractual_Lbs = ContractLbs
WHERE TheWhere/FilterClauseOfYourSubForm

Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top