Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: Me

Geek News

Me
"JB" <somehow[ at ]somewhere> 11/30/2008 12:45:50 PM
I looked up what 'Me' in Help and this is what it says:

<<The Me keyword behaves like an implicitly declared variable. It is
automatically available to every procedure in a class module. When a class
can have more than one instance, Me provides a way to refer to the specific
instance of the class where the code is executing. Using Me is particularly
useful for passing information about the currently executing instance of a
class to a procedure in another module. >>

Can someone please translate
Ta


Re: Me
Rick Brandt <rickbrandt2[ at ]hotmail.com> 11/30/2008 3:03:16 PM
On Sun, 30 Nov 2008 12:45:50 +0000, JB wrote:

[Quoted Text]
> I looked up what 'Me' in Help and this is what it says:
>
> <<The Me keyword behaves like an implicitly declared variable. It is
> automatically available to every procedure in a class module. When a
> class can have more than one instance, Me provides a way to refer to the
> specific instance of the class where the code is executing. Using Me is
> particularly useful for passing information about the currently
> executing instance of a class to a procedure in another module. >>
>
> Can someone please translate
> Ta

"Me" only applies to Class modules. It is a pointer to the current
instance of that class.

While user-created class modules are normally only used by advanced
Access developers the exception to that is that every form and every
report is actually a class.

So, in a form or report's module "Me" refers to the current instance of
that form/report. Therefore you can refer to a collection of the
form/report with Me!CollectionName and you can refer to
properties/methods of the form/report with Me.PropertyOrMethodName.

The alternative would be a fully qualified reference like...

Forms!FormName.PropertyName

There are numerous advantages of using Me.

1) It is shorter to type

2) It is actually a quicker reference for Access to resolve.

3) You can copy code from one form/report to another or rename a form/
report and the code still works.

4) If you open multiple instances of a class at the same time Me ensures
that the reference is made to the current instance.

As you might guess Me can only be used within VBA code contained in the
module of the class running the code. You can't use it in expressions or
queries.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Re: Me
"JB" <somehow[ at ]somewhere> 12/2/2008 10:12:59 AM
Thank you Rick, that made a lot more sense to me.
I'm working my way through learning VBA, but sometimes the explanations are
not all that clear.
J

"Rick Brandt" <rickbrandt2[ at ]hotmail.com> wrote in message
news:UWxYk.7796$D32.6289[ at ]flpi146.ffdc.sbc.com...
[Quoted Text]
> On Sun, 30 Nov 2008 12:45:50 +0000, JB wrote:
>
>> I looked up what 'Me' in Help and this is what it says:
>>
>> <<The Me keyword behaves like an implicitly declared variable. It is
>> automatically available to every procedure in a class module. When a
>> class can have more than one instance, Me provides a way to refer to the
>> specific instance of the class where the code is executing. Using Me is
>> particularly useful for passing information about the currently
>> executing instance of a class to a procedure in another module. >>
>>
>> Can someone please translate
>> Ta
>
> "Me" only applies to Class modules. It is a pointer to the current
> instance of that class.
>
> While user-created class modules are normally only used by advanced
> Access developers the exception to that is that every form and every
> report is actually a class.
>
> So, in a form or report's module "Me" refers to the current instance of
> that form/report. Therefore you can refer to a collection of the
> form/report with Me!CollectionName and you can refer to
> properties/methods of the form/report with Me.PropertyOrMethodName.
>
> The alternative would be a fully qualified reference like...
>
> Forms!FormName.PropertyName
>
> There are numerous advantages of using Me.
>
> 1) It is shorter to type
>
> 2) It is actually a quicker reference for Access to resolve.
>
> 3) You can copy code from one form/report to another or rename a form/
> report and the code still works.
>
> 4) If you open multiple instances of a class at the same time Me ensures
> that the reference is made to the current instance.
>
> As you might guess Me can only be used within VBA code contained in the
> module of the class running the code. You can't use it in expressions or
> queries.
>
> --
> Rick Brandt, Microsoft Access MVP
> Email (as appropriate) to...
> RBrandt at Hunter dot com

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net