Activate a button when data is updated

  • Thread starter Thread starter Holly Howard
  • Start date Start date
H

Holly Howard

I have a couple of fields that can be changed by the user. When they update
them the user is supposed to click the "Calculate" button. Unfortunately
people are forgetting to click the calculate button before closing out.

I would like to have the button automattically activate when one of the
three fields is updated.

I would be using the on change event but am having trouble coding for the
button activation.

Can anyone help?
 
In the After Update event of each text box:
Me.cmdCalculate.Enabled = True

In the form's Current event:
Me.cmdCalculate.Enabled = False

However, there are a few points here. Calculations should generally be done
on the fly, rather than storing the calculation results. If you are going
to store the calculation results, you may need to go to some trouble to
assure the calculation is performed, expecially if it require an action by
the user. In the rare situation in which you need to store the result you
should probably perform the calculation automatically, perhaps in the form's
Before Update event. If you insist on having the user perform an
(unnecessary) action such as clicking a button, you could use the Before
Update event to compare the OldValue property of each text boxes to its
Value property. If they don't match, Cancel the update and send the user
back to the form to click the button.

Since it seems any change in the value means the calculation needs to be
performed again, there is a very good argument for not storing the
calculation.
 
Back
Top