When I'm writing code for my open form in Access 2003 should I use Me.ControlName or just the ControlName

When I'm writing code for my open form in Access 2003 should I use Me.ControlName or just the ControlName? Is one better than the other? Or doesn't it really matter?
Ian LeasonAsked:
Who is Participating?
 
Dale FyeCommented:
It is recommended to use the me.ControlName syntax.

Oh, and make sure you are using a control naming convention that allows you to tell what type of control you are working with.  By default, Access will give the control the name of the field it is bound to, but if this is a textbox, I recommend prefacing it with "txt_".  If a combo, use "cbo_"

I use my own variant of the Reddick method
0
 
Ian LeasonAuthor Commented:
That is brilliant, thank you!
0
 
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
I would add that either will work, but as a general rule of thumb, you *always* want to be as explicit as possible in a programming language.

 Also, this would lead to less possible bugs.  For example:

 TransDate = Now()

 But was that supposed to be Me.TransDate or rst![TransDate] (since you were working with a record set at the time as well)?    If your not explicit, you leave the door open more for mistakes to be made.

 I would also take five minutes and have a look at this:

http://www.experts-exchange.com/videos/536/MS-Access-Writing-Solid-VBA-Code.html

 for a few more pointers in writing VBA code.

Jim.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Ian LeasonAuthor Commented:
Thank you Jim.
0
 
IrogSintaCommented:
In addition, using Me invokes IntelliSense, which helps to prevent misspellings when you're not sure of the control name.

Ron
0
 
Ian LeasonAuthor Commented:
I never thought of that, thank you Ron.
0
 
IrogSintaCommented:
@Jim Dettman,  Great video tutorial you made there, Jim.

Ron
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.