Me! is history ?


Question

Don't use Me!. It's simple. Just get out of the habit. I must confess that when writing the Access 97 Developer's Handbook, we didn't know this at the time. But for the current one, Me! is history.

Answer

From: Shamil Salakhetdinov <shamil@marta.darts.spb.ru>
Subject: Re: Key word "Me" with or with our?
Date: 25 Februay 1999 21:24

Ken,

I've nothing against dot (.) operator - it's easier to type etc. - but I remember the trouble I had when I converted Acc2.0 apps to Acc97 (I skipped Acc95) - this was the time when I had to manually edit dot operator which was forbidden to use to refer to recordsets' fields without compatibility layer. This time I decided (after reading help) to start to use dot and bang operators probably less effective but more systematic way - use bang (!) to refer to objects' instances (members of default collections) which are user defined (forms, reports, their controls and fields of forms' underlaying recordset, documents, tabledefs, querydefs, fields,...) and use dot (.) in all other cases...

I wouldn't mind to forget about bang at all if I'll see that MS is going to forget it too forever... But I'm not sure they do that in near future, if they do that at all...

The main tendency in VBA is that it becomes more and more strongly typed - are you sure that one fine day MS will not forbid to use dot (.) operator to refer to the controls of Form? Your example shows that you can create control named Name but you cannot refer to it using dot -me.Name - because Form has Name property - and you even don't see it in Object Browser but you can refer to it using bang - Me!Name. Isn't it an indirect sign that bang is more systematic way to refer to controls even if it is slower as you write - but is it slower? Let's check?...

Wasn't it the same reason used by MS when they decided to forbid dot usage with fields that it wasn't possible to resolve the reference used with recordset when one wrote:

dim rst as recordset
rst.Name = ...

Is it recordset's Name property or field's reference (named Name)? Aren't you afraid that one fine (in fact bad) day MS will decide to solve ambiguity they have with Form.Controls reference the same way they did that with recordsets?

And this is from MSAcc97 Online Help:

"Guidelines for naming fields, controls, and objects"

Another way to avoid unexpected results is to always use the ! operator instead of the . (dot) operator to refer to the value of a field, control, or object. For example, the following identifier explicitly refers to the value of the Name field rather than the Name property: [NameInfo]![Name]

See also "Use the ! and . (dot) operators in expressions" topic.

Is Me! history?

Shamil


HOME    TOPICS

Copyright © 1999 by Shamil Salakhetdinov.
All rights reserved. Terms of use.

Last updated: October 10, 2006

Published also here at 4TOPS: Me! is history ?