Refer all control's "AfterUpdate" event to the same procedure

G

Guest

Hi,

I have a form with numerous controls. I want to be able to programatically
set all the control's event procedures to a single procedure.

For example - I want all controls AfterUpdate event to point to another
procedure located in the form itself.

I tryed this:
Dim Ctrl as Variant
For Each Ctrl In Me.Controls
If (Ctrl.ControlType = acCheckBox) Or (Ctrl.ControlType = acComboBox)
Or (Ctrl.ControlType = acTextBox) Then Ctrl.AfterUpdate = "Proc1()"
Next Ctrl

But this just set the the name....

how can i do this ?
 
G

George Nicholson

Ctrl.AfterUpdate = "=Proc1()"

When AfterUpdate fires, Proc1 will be called.

HTH,
 
G

George Nicholson

"It's not working.."

Proc1 is never called or Proc1 isn't doing what you expect?
 
G

Guest

Well,

I solved the problem.
The function cannot be called from the form's module. If the function is
located in a general module it can be called. So I wrote the function in a
general midule and send the form's name to the function.

This way, the general module's function called the public function within
the form's module.

Thank's anyway

Daniel
 
G

George Nicholson

Glad you got it working.

In hindsight,
Ctrl.AfterUpdate = "=Forms!MyFormName.Proc1()"
*might* have worked...?

I have used VBA to set the BeforeUpdate property of a Form to call a Public
function within a General module (to update all Timestamp related fields),
but I've never tried setting it to call a function within that form's
module. You may have found the only workaround.
 

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