Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple: Call some form code from a module.

Status
Not open for further replies.

Petemush

Technical User
Jun 21, 2002
255
GB
How do I call the AfterUpdate code from a control on a form from a module?

Tried Call form1![Cost type].AfterUpdate

where form1 has been declared as the relevant form name but that doesn't work. Any ideas?

Cheers,

Pete
 
Pete,

A couple of pre-requisites to allow this to work:

(a) The form must be open when you attempt to call the procedure.
(b) The AfterUpdate procedure must be defined as PUBLIC, as opposed to PRIVATE, in order for it to have scope outside of the form. To do this, go into the code behind the form and change the line:

Private Sub Form_AfterUpdate()

to
Public Sub Form_AfterUpdate()

(c) The syntax for the calling of the procedure is as follows:

Forms!frmYourFormName.Form_AfterUpdate

Replace frmYourFormName with your form name, and note the inclusion of the "Form_" prefix before "AfterUpdate"; this is the way Access named the event, so the Form_ must be included.

This should hopefully do the trick,
Cheers,
Steve
 
Cheers Steve,

Typical me:

Tuesday Evening, going home - "I must remember to set the AfterUpdate event scope to public tomorrow.

Wednesday Morning - "Why isn't my code working?"

Thanks,

Pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top