What is Me?

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

Guest

I am new to coding with acess and was wondering what the Me is all about. I
see examples showing Me.Visible or Me![FieldName], what is this variable?
 
"Me" is a reference to the form or report the code resides in. For instance,
if you have code in the form "frmEmployee" and you want to reference the
text box "txtFirstName", you can use either:
Forms!frmEmployee!txtFirstName
or
Me!txtFirstName
 
Me is a shortcut way of referring to the current form, in VBA code.

For example, if the form is called Form1, then:
Me.City
is the same as:
Forms.Form1.City
 
From the Help file:

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:

Sub ChangeFormColor(FormName As Form)
FormName.BackColor = RGB(Rnd * 256, Rnd * 256, Rnd * 256)
End Sub

You can call this procedure and pass the current instance of the Form class
as an argument using the following statement:

ChangeFormColor Me
 
Back
Top