Whats Me. ? (1 Viewer)

Loranga

Registered User.
Local time
, 20:43
Joined
Sep 14, 2010
Messages
13
Aloha,

I have bought a couple of acces books (but they havent been delivered yet) hopefully they can straighten things out for me but in the meantime I post a question here.....

Trying to learn Access I stumble on different code with the the "prefix" Me.
EG.
Code:
Me.txtOne.Value = Me.cboCompany.Column(1)

What does that mean?
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 13:43
Joined
Jan 20, 2009
Messages
12,853
Me refers to the form or report that the VBA module belongs too.
 

Loranga

Registered User.
Local time
, 20:43
Joined
Sep 14, 2010
Messages
13
Ok that make sense.
Thanks for clearing that out
 

boblarson

Smeghead
Local time
, 20:43
Joined
Jan 12, 2001
Messages
32,059
Me refers to the form or report that the VBA module belongs too.

Slight correction there Galaxiom -

boblarson said:
This is a programming shortcut which lets the programmer refer to the current CLASS object. Most of the time, in Access, you would be referring to a form or report using this. It can also apply to custom classes as well, but is less prevalent unless custom classes are being used.
Let's say you have a form named "frmMain" and you have a text box there called "txtEntry" and you wanted to refer to that text box in code. A fully-qualified reference would be Forms!frmMain.txtEntry but you could also refer to it using the shortcut (as long as the code is ON frmMain): Me.txtEntry

So it isn't just for a form or report. It is the current CLASS OBJECT which is being referred to. I thought I should point out that it was more than just for a form or report.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
, 22:43
Joined
Feb 28, 2001
Messages
27,200
And a further note is in order.

If you have a class object such as a form and some VBA code in that class object, then in that code you can use Me. to refer to the class object, its collections, properties, and methods. Woks fine UNTIL you call code that is in a general module. For the construct Me. to work correctly, it must be contained within the class module to which it refers. If you call a general module and try to use Me. inside the called code, it won't work. However, if you needed to refer to your class object inside the general module code, you can pass Me. as an actual parameter in the call sequence of the called code. The formal parameter would have to be a form or report object.
 

Users who are viewing this thread

Top Bottom