Call a sub or function on a subform from another form (1 Viewer)

hk1

Registered User.
Local time
Today, 12:29
Joined
Sep 1, 2009
Messages
121
I need to call a subprogram on a subform. I'm not going to be calling this sub from the main form. I need to call it from an outside form. How can I do this?
 

Khalid_Afridi

Registered User.
Local time
Today, 21:29
Joined
Jan 25, 2009
Messages
491
you should create a public function/sub routine with the Public key word in general section of the class to call it from anywhere in your project.

The sub routine with the Private key words in the form can only be called within the current form.
 

hk1

Registered User.
Local time
Today, 12:29
Joined
Sep 1, 2009
Messages
121
Sorry, Khalid, I already knew that. I just wanted to know what code to use to call the function/sub.

I tried the following and none of them worked. Note that the name of the sub I'm trying to call is "subRefresh":
Code:
Call Forms!frmMainFormName!fsubSubFormName.subRefresh
Call Forms!frmMainFormName!fsubSubFormName.Form.subRefresh
Forms!frmMainFormName!fsubSubFormName.subRefresh
Forms!frmMainFormName!fsubSubFormControlName.Form.subRefresh
What I finally had to do was put a sub on my mainform. I would have then called the sub on the subform but that wasn't necessary since I was doing a refresh/requery on my subform. Here's how I call the sub on the main form:
Code:
Call Forms("frmMainFromName").subRefreshPO
subRefreshPO just has this line of code:
Me.fsubSubFormControlName.Requery
 

Users who are viewing this thread

Top Bottom