Refer to Sub on Parent Form

B

Brad

Thanks for taking the time to read my question.

I have a form with a sub form. I need to run a sub (code) on the parent form
from the subform, but I can't figure out how.

I've made the sub (code) on the parent form a Public sub but that made no
difference.

Thanks,
Brad
 
M

Marshall Barton

Brad said:
I have a form with a sub form. I need to run a sub (code) on the parent form
from the subform, but I can't figure out how.

I've made the sub (code) on the parent form a Public sub but that made no
difference.


Since a form's module is a Class module, its public
functions and subs are methods of the class. This means
that you would need to use the syntax object.method

In the case of a subform calling a main form sub, it could
simply be:
Parent.nameofsub arglist
 
B

Brad

Thanks for the quick reply Marshall.

Here is an example of one idea that I tried.

Forms!frmSwitchboard!frmMaintCellInfo.cmdFindOwner_Click

I get the error - "Run-Time error '438': Object doesn't support this
property or method

I've tried without the Forms!

frmSwitchboard.frmMaintCellInfo.cmdFindOwner_Click

error: Run-time error '424': Object required

Not sure what else to try.

Thanks again,

Brad

Brad
 
B

Brad

I just had a thought and gave it a try...

Me.Parent.cmdFindOwner_Click

This worked.

Thanks Marshall, you set me on the right track.

Brad
 

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