RE: What is the meaning & use of "& ME!"?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi Ashton,

The "Me" keyword is a self-identifier for referencing a property or value
within the forms own class module (the code behind the form). This allows
you to set or get values while ensuring that you don't have naming collisions
in those cases where you may have multiple forms open that have the same
variable names being used.

For example, if you want to set the value of a textbox something, you would
use:

Me.txtUserName = "Bob"

This will place the name Bob inside the textbox that is on your form. It
can be viewed as a shortcut to void having to type:

Forms!frmCustomerInformation!txtUserName = "Bob"

Personally, I find that using Me makes it a bit easier to read than the later.

And lastly, if you were to use the later example and fully namespaced
everything and then later decided that you wanted to change the name of the
form or the txtUserName field to something else, you would effectively break
your code everywhere you used it, but the Me keyword ensures that the proper
object is referenced no matter what you do (outside of changing the name of
the field). This makes debugging a lot easier.

Hope this helps a bit.

Lance



"Ashton" wrote:

> In the VB section I find this combination constantly but have not been able
> to find it in the documentation so I can use it properly.
.



Relevant Pages

  • RE: How do I search by text in Access?
    ... Use the Like operator in conjunction with the * wildcard. ... to open a query which references the textbox. ... > I'm using Access 2000 and I am creating a Question and Answer database. ... > questions and answers matching the keyword or text that the user entered. ...
    (microsoft.public.access.forms)
  • Update textbox with found result!
    ... I got a textbox with name = action, whn a key is press it ... sends a query to database grabs data from server n send data back ... and is sent to the script, script look for ne word start with the ... Try searching for 1 keyword when found click on it, ...
    (comp.lang.javascript)
  • Re: Reference If Statement Result
    ... Referencing the textbox itself is not a big problem; ... contain your unbound textbox. ... > is no longer unbound seeing it has an IIF statement in it)? ...
    (comp.databases.ms-access)
  • Re: how can I implement hit hightlighting?
    ... One approach you could use is with using a regular expression to trap the ... keyword in the Characterization and replace it with styled text. ... Your Search form contains a textbox in which you would enter the search ... Note that the Regex object is using the regular expression operand "\b" to ...
    (microsoft.public.inetserver.indexserver)
  • Re: Reference a subform
    ... Allen Browne - Microsoft MVP. ... "Leonard" wrote in message ... >>> 'zoomed' to a bigger textbox on a popup form. ... >>> And, is this called explicit or implicit referencing, or something ...
    (microsoft.public.access.modulesdaovba)