Event from Calculated Control

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can someone explain why this isn't working and what I need to do to make it
work. I have a form with three fields that need users to input a number value
and a fourth field on the same form which calculates the average of the three
values the user inputs. This works fine but I want a message box to appear
when the calculated average in the fourth field exceeds a certain value and I
can't get this to work - BeforeUpdate, AfterUpdate, Change won't trigger my
VBA MsgBox code even though the calculated average has exceeded the limit I
set.
TIA
 
You need to do the check in the AfterUpdate events of the *other* three
controls, the ones that accept user input. You may also want to add it to
the Current event procedure of the form, so that the control is updated when
browsing through records. Rather than repeating code in multiple event
procedures, put the common code into a procedure or function, and call that
procedure or function from the event procedures.
 
Alan said:
Can someone explain why this isn't working and what I need to do to
make it work. I have a form with three fields that need users to
input a number value and a fourth field on the same form which
calculates the average of the three values the user inputs. This
works fine but I want a message box to appear when the calculated
average in the fourth field exceeds a certain value and I can't get
this to work - BeforeUpdate, AfterUpdate, Change won't trigger my VBA
MsgBox code even though the calculated average has exceeded the limit
I set.
TIA

You would need that to be in the AfterUpdate event of all three TextBoxes
that the user types in. The box with the calculation does not have any
events fire just because its calculation result changes.
 
Brendan Reynolds said:
...Rather than repeating code in multiple event
procedures, put the common code into a procedure or function, and call that
procedure or function from the event procedures.

I'd like to see an example of that approach. Northwind?
 
I'm not intimately familiar with Northwind. It is certainly quite likely
that there is an example in there somewhere, but I could not say for sure.
 
Taking it one step further, if you use the before update events, you will
have a way to cancel should you need to.
 
Thanks everyone. Problem solved.
Alan

Bill Mosca said:
Taking it one step further, if you use the before update events, you will
have a way to cancel should you need to.
 
Back
Top