Accessing a sub-form sub from a custom right-click menu

B

Bill Hicks

I've searched everywhere I could possibly search, with no answer to the
following question. Sorry if this has been discussed before, but searching
the archives yields no suitable answer.

I have a form that has a sub-form. I've created a custom context menu so
that right-clicking on a listbox on the subform displays my custom
right-click menu. I want to call a sub on the subform, but I have not
figured out a way to accomplish this. Of course I need to call the open
instance of the form/subform because certain information is only available
on the subform object.

Is there a way to do this? I tried creating a public sub in a global module
I use for lots of other procedures, but I'm not sure how to find the
subform/sub. I've also tried several variations on the "Screen.ActiveForm"
method to no avail.

Any suggestions appreciated.

Bill
 
S

SteveM

For a start, you will need to use a Public Function, not a Sub. Custom menus
need to reference Functions.

Then in your Public Function, try this:
Call Forms!MyForm!MySubformControl.Form.MySub

The Sub you are calling also needs to be Public
Steve
 
B

Bill Hicks

Thanks, Steve! That did the trick (I did have to change the '!' characters
to '.' to make it work). I had determined last night that you could only
call functions from the custom menus, not subs. Thanks for the
clarification.
 

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