Johan_Koers
May 29 2007, 09:50 AM
Iám trying to call a function on subform (main form has 2 subforms)
Lets say function name on the subform is Function1 and name of subforms is Subform2
I tried:
Call Me.subform2.Form.Function1 (din't work)
Annyone ideas?
niesz
May 29 2007, 09:54 AM
Is your function Public?
Johan_Koers
May 29 2007, 10:00 AM
I tried Public Function and Public Sub on the subform
CarlKopp
May 29 2007, 10:01 AM
Try placing your function in a module rather than in the VBA editor of the form or subform.
Press Alt-F11 to get to the VBA Editor.
Press Ctrl-R to open the Project Explorer
Right-Click the "Modules" folder.
Select Insert Module.
Place your function there, and as niesz suggested, declare it as public.
Johan_Koers
May 29 2007, 10:06 AM
Putting the function in a module is not possible becouse it refers to a lot of fields.
And one subform is used 2 times in the mailform.
I need something like Call Me.subform2.Form.Function1
CarlKopp
May 29 2007, 10:24 AM
Based on the information provided, it looks like you want to pass arguments from the form and subform through the function. If so, your syntax would be something along the lines of the following:
valMyValue = Function1(arg1, arg2, arg3, etc.)
... and the function itself would be something like the following:
Public Function(arg1, arg2, arg3, etc.) as Double '(or as String, as Boolean, as Integer, etc.)
...
...
...
End Function
You should be able to pass values through a function regardless of from where the values originated.
Also, you would not use the "Call" keyword with a function. You use "Call" with a subroutine.
niesz
May 29 2007, 10:31 AM
You have to use a Public Function. You can call it from the main form even if it is on the subform. You can preface it with the optional word "Call"
You must reference it like:
Me.NameOfSubFormControl.Form.FunctionName
datAdrenaline
May 29 2007, 01:14 PM
If it is declared as a Public Function (or Sub) ... AND it is uniquely named, you do not need full qualification ..
In the Sub Form code ....
CODE
Public Sub btnMyButton_Click()
'Do Something
End Sub
In the Main form code
CODE
.
.
.
btnMyButton_Click
.
.
.
... But ... FULL Qualification and prevent issues that may come about if you have to declare another block of code with the same name as PUBLIC.
Johan_Koers
May 30 2007, 04:01 AM
I ve got it working with Me.NameOfSubFormControl.Form.FunctionName.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.