Me

  • Thread starter Thread starter JB
  • Start date Start date
J

JB

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
 
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.
 
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
 
Back
Top