running a subroutine from the parent form

C

Chegu Tom

Hi

I have a Main form called OpenLesson with a subform called SuggestedLesson
displayed as a datasheet

I have a button on the OpenLesson form called cmdRunSuggestedthat takes
information from the current record in the subform and starts a lesson.

I would like to call the code behind the button cmdRunSuggested_Click by
double clicking a control in a record in the subform.

Forms!parent!cmdRunSuggested_Click
Forms!OpenLesson!cmdRunSuggested_Click

didn't work form me. What syntax do I need for this

Thanks
 
D

Dorian

Your syntax is not right you need to execute a procedure inside a form.
Since forms each have their own code modules, you will be running a module
in a different form. You therefore have to make the module PUBLIC rather than
PRIVATE.
I would create a PUBLIC module independent of any event and call it from the
event.
In the OpenLesson form you should have:
PRIVATE SUB cmdRunSuggested_Click()
<code>
END SUB
change this to
PRIVATE SUB cmdRunSuggested_Click()
Call RunMyCode()
END SUB
PUBLIC SUB RunMyCode
<code>
END SUB
Now in your SuggestedLesson form you can also 'Call RunMyCode()' from
wherever you want.
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".
 

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