Repeat afterupdate code

J

jtfalk

Hello,

I have a form that has about 25 inputs for data. I then have about 15 boxes
that I just calculate some numbers so people can see what the effects are as
they enter it. So for every data entry point I have the code behind
AfterUpdate calling

Private Sub Start_number_AfterUpdate()
Call Calculations
End Sub

Private sub Calculations()
.....
End sub

Is there a way to have the calculation boxes all update after any of the
data entry points have without have to put in the afterupdate behind each
one? It works fine the way it is right now but I would like to clean it up.
 
M

Marshall Barton

jtfalk said:
I have a form that has about 25 inputs for data. I then have about 15 boxes
that I just calculate some numbers so people can see what the effects are as
they enter it. So for every data entry point I have the code behind
AfterUpdate calling

Private Sub Start_number_AfterUpdate()
Call Calculations
End Sub

Private sub Calculations()
....
End sub

Is there a way to have the calculation boxes all update after any of the
data entry points have without have to put in the afterupdate behind each
one? It works fine the way it is right now but I would like to clean it up.


The event properties can contain a function call, macro name
or, as you are now using, [Event Procedure]

To do what you want, replace the [Event Procedure] with:
=Calculations()
 
S

Stuart McCall

jtfalk said:
Hello,

I have a form that has about 25 inputs for data. I then have about 15
boxes
that I just calculate some numbers so people can see what the effects are
as
they enter it. So for every data entry point I have the code behind
AfterUpdate calling

Private Sub Start_number_AfterUpdate()
Call Calculations
End Sub

Private sub Calculations()
....
End sub

Is there a way to have the calculation boxes all update after any of the
data entry points have without have to put in the afterupdate behind each
one? It works fine the way it is right now but I would like to clean it
up.

Put Calculations() in a standard module and make it public:

Public sub Calculations()

Then in form design view, select all the relevant controls and put this:

=Calculations()

in their AfterUpdate event properties (instead of [Event Procedure])
 
J

John W. Vinson

Put Calculations() in a standard module and make it public:

Public sub Calculations()

Then in form design view, select all the relevant controls and put this:

=Calculations()

in their AfterUpdate event properties (instead of [Event Procedure])

nitpick: I think you need to define it as Public Function Calculations(), not
Public Sub.
 
S

Stuart McCall

John W. Vinson said:
Put Calculations() in a standard module and make it public:

Public sub Calculations()

Then in form design view, select all the relevant controls and put this:

=Calculations()

in their AfterUpdate event properties (instead of [Event Procedure])

nitpick: I think you need to define it as Public Function Calculations(),
not
Public Sub.

You're right, John. My mistake. Actually, thinking about it, the routine
could stay in the form's module, so long as it's a function.
 

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