Can an event on a form be called from a module?

  • Thread starter Thread starter BobV
  • Start date Start date
B

BobV

Group:

Can an event on a form be called from a VBA module? For example, after the
VBA code in the module enters a value in the COST field of the form, I would
like to call the Cost field's After Update event (Private Sub
Cost_Fed_AfterUpdate). By calling the After Update event, this will force
the form to be recalculated. I know that I will have to remove the word
Private from the After Update event, but I don't know what the VBA code
would be to refer to the event.

What is the VBA statement to reference the Cost_Fed_AfterUpdate event that
is located on the form named Form1 (if this can be done)?

Thank you for your help.

BobV
 
Try:
Call Form_Form1.Cost_Fed_AfterUpdate()

If you look in the title bar of the form's module (code window), you will
see that Access uses this kind of "Form_" prefix to refer to the module.
 
Yes, you can call After Update event from module, but better make a public
method in a form to call, where you call Cost_Fed_AfterUpdate

So make a public sub CallCostFedAfterUpdate, add call to
Cost_Fed_AfterUpdate there, then you can run it (in case form1 is loaded):

forms("Form1").CallCostFedAfterUpdate
 
Back
Top