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

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
 
A

Allen Browne

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.
 
A

Alex Dybenko

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
 
B

BobV

Allen and Alex:

Thank you very much for your help. This is what I was looking for.

BobV
 

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