Call Public Sub from other form

  • Thread starter Thread starter Mr. Smith
  • Start date Start date
M

Mr. Smith

Hi
I try to call a Public Sub procedure from outside the actual form it is
connected to.

In example I use this statement sucessfully:
Forms!frm_myform.Form.Form_load
to run the Public Sub Form_load procedure from another form

In this case I have an AfterUpdate procedure on a combo box which I want to
initialize from another form, but the below statement will not work.
Forms!frm_myform.Form.cboMyClients_AfterUpdate
I get "Application defined or objectdefined error"

Please give me a hint if you have suggetstion to why this is not working, or
have a "smoother" routine to call a procedure from outside the actual form
it is placed.

Regards
Mr. Smith
 
Here's a snippet from the Access Help file about calling a procedure from
another form:

You can also create a new instance of the form that is being used as a
subform, even if neither the main form nor the subform is open, and call the
procedure. This will work for any form, whether or not it is being used as a
subform. The following example shows how to create an instance of the Orders
Subform and call the GetProductID procedure:

Dim frm As New [Form_Orders Subform]
frm.GetProductID
Note When you create a new instance of a form with a name consisting of
more than one word, enclose the class name of the form in brackets, as shown
in the preceding example.
 
Back
Top