Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / March 2005

Tip: Looking for answers? Try searching our database.

Problems with me. in function.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Stefan - 20 Mar 2005 11:29 GMT
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
Douglas J. Steele - 20 Mar 2005 12:59 GMT
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)

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> Hello,
> Who can help me with this problem.
[quoted text clipped - 21 lines]
> Help,
> Stefan
Stefan - 20 Mar 2005 14:03 GMT
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
Douglas J. Steele - 20 Mar 2005 15:07 GMT
What error do you get?

I guarantee that what I've suggested works.

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> Doug,
>
[quoted text clipped - 10 lines]
> Thanks anyway.
> Stefan
Stefan - 20 Mar 2005 15:31 GMT
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.
Stefan - 20 Mar 2005 15:36 GMT
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 ??
Douglas J. Steele - 20 Mar 2005 16:53 GMT
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.

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> Sorry, I saw something.
>
[quoted text clipped - 5 lines]
>
> Or can I ??
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.