Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Me" statements 2

Status
Not open for further replies.

lrumd

Technical User
Sep 5, 2002
25
0
0
US
In the following statement, what exactly does the "Me" mean, and where can I read about this?

Set rs = Me.Recordset.Clone

I am suspicious that the "Me" refers to the current form. Am I totally off track?

Thanks

Luis [atom]
 
Hi

No, you are spot on track, it referes to the form in which the code resides, so Me. is only valid in a Form code module

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
UK
 
Suppose you have an open form "MyForm"
From within the form, you can refer to the Form object in one of the following ways:

Forms![MyForm] (general Access notation)
Forms("MyForm") (general VB notation)
Me

The same goes for reports:
Reports![MyReport]
Reports("MyReport")
Me

In conclusion, Me refers to the form or report where the code resides. Using Me in a module will generate a compile error.

Many times it can be ignored, so:
Me.RecordsetClone
can be successfully replaced by
RecordsetClone

It's a matter of personal preference if you use it or not. I use it when I am too lazy to type a full property name. Using Me enables the wonderful VB dot thing which speeds up code development.

And a tiny notice:
RecordsetClone is just one word, not two separated by a dot.

HTH [pipe]
Daniel Vlas
Systems Consultant
danvlas@yahoo.com
 
Thank you, Dan, and Ken. I don't have to say "Forms![MyForm]" before I can refer to it by "Me", do I?

Thanks

Luis [atom]
 
No, you don't. Actually, if you do, you will get an error [smile].
[pipe]
Daniel Vlas
Systems Consultant
danvlas@yahoo.com
 
The reason "Me" exists is to make code potentially more 'transportable'.

As Dan and Ken have mentioned Me refers to the form or report where the code resides. so any standard bits of code that you have that need to refer to the current form object can be dropped into the Form's code and you do not need to refer to the form explicitly by name.
( same for Reports )

Eg.
Requery the current form
Me.Requery

Open a Report using the Current Form's existing Filter property as the selection criteria for the Report
DoCmd.OpenReport "rptReportName", acPreview, , Me.Filter

etc.


'ope-that-'elps.




G LS
accessaceNOJUNK@valleyalley.co.uk
Remove the NOJUNK to use.

Please remember to give helpful posts the stars they deserve!
This makes the post more visible to others in need! :-D

 
In addition to all this, me. is evidently a bit faster than forms!ThisForm. I'm sure that on any computer I'd be willing to use, that efficiency is trivial, but there you have it.

Jeremy =============
Jeremy Wallace
Designing, Developing, and Deploying Access databases since 1995.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top