Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / February 2006

Tip: Looking for answers? Try searching our database.

What does Me. mean?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
btee - 28 Feb 2006 19:17 GMT
I'm new to using VBA and have a question.  What does Me. mean when used in
code for forms?  I've seen that in several postings, but have no clue what it
means.
Ofer - 28 Feb 2006 19:41 GMT
"Me" stand for the current form where the code (Me) is located on.

So instead of writing the full path
Forms![FormName]![FieldName]

you can write
Me.[FieldName]

As long that this code is located in the FormName and there is a field
called FieldName

Signature

\\// Live Long and Prosper \\//
BS"D

> I'm new to using VBA and have a question.  What does Me. mean when used in
> code for forms?  I've seen that in several postings, but have no clue what it
> means.
Tom Lake - 28 Feb 2006 19:44 GMT
> I'm new to using VBA and have a question.  What does Me. mean when used in
> code for forms?  I've seen that in several postings, but have no clue what it
> means.

It refers to the current form.  If you have a control named MyControl on the active
form,
then Me!MyControl (or not as nicely, Me.MyControl) refers to that control.  Why I use
the bang (!) rather than the dot(.) is because the bang really should be used to
refer to
control names and the dot to properties. Me!MyControl.Text would refer to the
contents
of text box MyControl on the current form.  Some people argue that control names ARE
properties of the form but I find it just leads to confusion.  Also, if you used a
reserved
word such as Name for a control name by mistake (a bad thing to do), Me.Name would
give an error whereas Me!Name would not.

Tom Lake
btee - 28 Feb 2006 20:01 GMT
Thanks for your responses - that really hepls a lot!!!

> > I'm new to using VBA and have a question.  What does Me. mean when used in
> > code for forms?  I've seen that in several postings, but have no clue what it
[quoted text clipped - 14 lines]
>
> Tom Lake
Mark Burns - 28 Feb 2006 21:39 GMT
Tom,

1) Last I heard/read, the ! syntax is being deprecated in future versions.
2) the "Me" object actually referrs to the current instance of the open form
(it is possible to have multiple instances of the same form open
simultaneously)

Thus, in code, forms!MyOpenForm!MyControl could be an ambiguous reference if
multiple instances of a form are open simultaneously (this is a problem for
queries too - if a query driving a combobox list has forms!myform!myControl
as a Where conditional expression, which instance of the "myform" form and
which copy of the control value will the query return when it executes?)

Within form VBA code, this potential ambiguty is eliminated by the use of
"Me."

Thus, my preference for "me.controls("myControl").value"-style syntax is
more bulletproof. Yes, it is more verbose, but this helps in another way: the
code is more self-documenting, so when you have to tweak something you
haven't looked at for 6+ months when you open it up, the code meaning is
easy(/easier) to discern (even for a different person). The terseness of the
!-style syntax works against code readability and maintainability IMO.

Also, with the  .-style syntax allows for more programming flexibilty and
increased data-drivability of your code. Consider that:
me.controls(strSomeControlNameVariableHere).value
allows you to programatically determine which control you are referencing at
run-time. Try that with your
"me!FixedControlNameHere.value"-syntax.

Oh...and Me.Name will return the name of the form as a string (...which it
is also the reason it is a bad idea to use "Name" as either Field or Control
names), but you knew that, right?     ;-)

> > I'm new to using VBA and have a question.  What does Me. mean when used in
> > code for forms?  I've seen that in several postings, but have no clue what it
[quoted text clipped - 14 lines]
>
> Tom Lake
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.