Problems with me. in function.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,
Who can help me with this problem.

I've got a few forms with the same subform on them. I also use a shortmenu
on this subform.

So, If I want to open a second form after I choose an item I've got to know
the recordnumber what i want to show in that 2nd form.

The problem is that the keyword me. is not available in the function. If I
use the exact code in a 'private sub' then it works correctly.

If I change me. into the name of the form it also works.
But it's not my intention to write several (the same) functions and just
changing the name of the form.

And if you make menu's or shortmenu's, you have to take functions, sub's is
impossible, is it??


Help,
Stefan
 
If your existing code has something like

Me.abcd

in it, the generic routine should have a parameter of type Form in it that
you use instead of Me:

Public Sub MyRoutine(WhatForm As Form)

WhatForm.abcd

When you're calling this routine from your various forms, use

Call MyRoutine(Me)
 
Doug,

I already tried it after a similar thread and answer on the Dutch version of
this Discussion Group. I keep getting an error.

For user-friendly reasons I use the selfmade Uppermenu as a shortmenu as well.
After some tryings it seems that I should make several functions instead of
an universal one.

Thanks anyway.
Stefan
 
I have a dutch version of access2000 but the error is something like
'The automation object Me is not situated in the object. (No error-nummer)'

I start the function with a macro because I must use a macro in the menu.
 
Sorry, I saw something.

You used Public Sub ... in your solution.

In a Sub it works, I know, but I can't get Subs in my menu's, I have to use
function's

Or can I ??
 
So change that to

Public Function MyRoutine(WhatForm As Form)

WhatForm.abcd

and if you're simply calling it in the event's property, to

=MyRoutine(Me)

No other change is required to change the sub to a function: it's not
mandatory that a function return a value.
 
Back
Top