I'm looking to take code I have in the OnClick event of a button and make it into a Function that can be used by several different subforms.
I have a button on a subform that currently calls a function.
The code above is an over simplified version of what I'm trying to do. When I run the Call from the click event I was getting an error everytime it saw "Me." anything. When I took them all out I now get an error "Object Required". What do I need to do to allow me to pass parameters to this function that relate to the subform the button is located on? Is a function what I should be creating?
I have a button on a subform that currently calls a function.
Code:
private sub test_button_Click()
Call example(test_button)
end sub
public function example(control_name as control)
control_name.caption = "whatever"
dim ctl as control
for each ctl In Me.Controls
msgbox ctl.Name
next
end function
The code above is an over simplified version of what I'm trying to do. When I run the Call from the click event I was getting an error everytime it saw "Me." anything. When I took them all out I now get an error "Object Required". What do I need to do to allow me to pass parameters to this function that relate to the subform the button is located on? Is a function what I should be creating?