From event covering update of any control

D

Duck

I have a form with many controls displaying prices of different
items. There are also other controls which determine which price is
displayed in any of the first group of controls. I would like to only
have to write the formula to total these price controls once. I would
like for them to be totaled whenever any control on the form is
updated. Is there a specific form event that I can use for this
purpose?
 
J

John W. Vinson

I have a form with many controls displaying prices of different
items. There are also other controls which determine which price is
displayed in any of the first group of controls. I would like to only
have to write the formula to total these price controls once. I would
like for them to be totaled whenever any control on the form is
updated. Is there a specific form event that I can use for this
purpose?

I'm really confused about your data structure here. Is this just an unbound
form, for the purpose of doing calculations? Or do you have a table or tables
behind it?

The AfterUpdate event of each control which "determines what price is
displayed" should work - there isn't any form-wide event that I can think of
(other than the Dirty event which fires when any bound control is manually
changed).

John W. Vinson [MVP]
 
P

Pat Hartman \(MVP\)

I solve this problem by putting the calculation in the query. That way the
result field on the form is bound to a field in the query and it will change
automatically each time you change any of the component fields. Don't
forget to take nulls into account in your calculation because there will be
times when it will run and one or more of the fields will be null.

The alternative is a sub that performs the calculation but you have to call
it in the AfterUpdate event of each component field.
 
Top