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

  • Thread starter Thread starter Guest
  • Start date Start date
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 ?
 
Ctrl.AfterUpdate = "=Proc1()"

When AfterUpdate fires, Proc1 will be called.

HTH,
 
"It's not working.."

Proc1 is never called or Proc1 isn't doing what you expect?
 
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
 
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.
 
Back
Top