Placement of Functions

B

Bill Mitchell

Hi,

I control much of the activity on my forms and subforms
with shortcut menus. These menus are based upon macros
which call various functions.

Sometimes I use the same subform on different forms. I
do not want to have to write a different function for
each form (due to location and naming issues); I would
rather be able to use the Me word which will allow the
function to act on the subform wherever it is.

This all works fine when I write the Function in a
seperate module and declare the specific location of the
subform for each instance.

However, if I embed the function within the form itself
(allowing me to use Me), Access says there is "no
function by that name" when I call it from the shortcut
menu. There is clearly a function with that name, so
what gives?

What am I doing wrong here and why cant my shortcut menu
see my function when it is embedded in my form? I tried
doing Public but that didnt help. I have other functions
embedded within forms that work just fine but arent being
called my shortcut menus.

Any help would be appreciated.

Bill
 
A

Allen Browne

To be able to reuse a function, place it in a standard module, and pass a
reference to the form. You can then use that reference where-ever you would
use "Me":

Public Function MyFunction(frm As Form)
'Use frm here where-ever you would use "Me".
End Function
 

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