The Me Property

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. For example, suppose you have the following procedure in a module:

The Me keyword contains an object reference to the current class instance, and can be used by code written in forms, reports, and user-defined classes. It returns faster than a fully qualified object reference, and is useful when you have several instances of a class. For example, if the following three code fragments are executed from the Employees form, they all refer to the value of the LastName text box on that form:

strLastName = Forms!Employees.LastName strLastName = Me!LastName

You can also use Me to pass information about the current class instance to a procedure in another module or class.

0 0

Post a comment