When to dot . and when to bang !
Posted on 2004-09-02
OK dudes and dudettes, this one isn't really a question but a question of programming syntax.
In many questions, I've seen this:
Now, I always use Me!SomeControl as the syntax when referring to control objects. Why? Well, although you do get Intellisense when using the . operator, there are disadvantages to using it. The main disadvantage is confusion between controls and properties. The easiest example of this is if you create a textbox on a form called Name (although we all know better than to do that, right?). When you do this:
Me.Name returns the form's name
Me!Name returns the value in the textbox called Name.
(and your control should never be given the same name as the field, but that's a whole different matter).
I recall that the best method of referencing controls is actually Me("Name") since that is how Access tokenises the code anyway, so doing that requires no additional translation by the engine.
Thoughts, feelings, inputs, general abuse? Or other comments on Access programming style and syntax?