Full Version: Referencing Control On A Subform In The Onclick Property
UtterAccess Forums > Microsoft® Access > Access Forms
Hi I have a form called "MotherForm" with a subform called "SubForm"'
On the subform I have a control called "myControl" and another text box called "myTextBox".
What I am having trouble with is I wish to call a function by clicking on "myControl" which passes the control value to a Public function called "OpenFile" with another parameter called "ftype".

The example is on the MyControl on click property I wanted to do something like this: =OpenFile([Screen].[ActiveForm]![myTextBox],"mine")
in the function I can then reference the Value in myTextBox and then do something with it.
This works well on the single form (not a subform) but when I use it in the subform it comes up with an error.

Can someone please help by providing how to reference myTextBox in a subform to pass it to a function.

Thanks in advance
Don't use Screen.ActiveForm.

Thanks so what do you suggest.
The sub-form can be used in multiple mother forms so specific referencing to the specific form names cant be done.
I currently use a sub procedure on the individual form but I have multiple instances of the same sub (procedure) in numerous sub-forms and am trying to make a single function to handle multiple instances on multiple forms.
So I wish to try and use the on-click event
Just reference the textbox.


I tried it with the [screen] etc before it. So the trick is not to reference any form.

Thanks again.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.