. (dot) or ! (exclamation mark)

  • Thread starter Thread starter Jaroslaw Stokowiec
  • Start date Start date
J

Jaroslaw Stokowiec

What is difference between . (dot) and ! (exclamation mark)?

I have field "fld1" and I'd like set it to 100. So:
me.fld1 = 100
me!fld1 = 100
Is any difference there?
 
You sometime hear that: "the ! refers to user-defined things and . refers to
Access-defined things." Although that is the standard rule of thumb, it is
not exactly correct. More precisely, the bang (!) serves to separate an
object from the collection which contains it, and the dot (.) serves to
separate one level of the DAO hierarchy from another.

Let me back up.

An Access object model (whether DAO or ADO) naming is hierarchical in
nature, sort of like DOS. And like DOS, you can refer to an object using a
fully qualified name or a semi-qualified name. In DOS, a fully qualified
name would be like this:

C:\MSOFFICE\ACCESS97\TEST.MDB

If you assume the default directory, you can refer to the file by it's
semi-qualified name: TEST.MDB.

So to, you can refer to an Access object by its fully qualified name:


DBEngine.Workspaces(0).Databases![c:\msoffice\access97\test.mdb].TableDefs!T
able1

or if you assume the default DBEngine (always), default Workspace, and
default Database, you can refer to the table by its semi-qualified name:

TableDefs!Table1.

If you look at the fully qualified name like this:
DBEngine.
Workspaces(0).
Databases![c:\msoffice\access97\test.mdb].
TableDefs!Table1

you can see the DAO hierarchy levels more easily and how the dot separates
them. (Much like the "\" in DOS).

The dot also serves to separate an object from its properties and methods,
which can also be thought of as another level in the hierarchy. So I can
refer to "TableDefs!Table1.RecordCount". RecordCount being a property of
Table1.

The bang (!) separates objects from the collections which hold them, thus it
separates "Table1" from the collection "TableDefs" and the object
"c:\msoffice\access97\test.mdb" from its collection "Databases".

Since most objects are named by you, and since levels of DAO hierarchy are
named by Access, we get the rule of thumb named earlier.

DAO Naming Rules:
1) The dot serves to separate one level of the DAO heirarchy from
another in a fully qualified object name.

2) The dot also serves to separate an object from its methods and
properties. (This, by the way, is the principle use for most people)

3) The bang serves to separate an object from the collection in which
it is contained.

ME is something of a special case in that the controls on a from are both 1)
a property of the form and 2) a lower level in the Object Model. I
generally use the dot with Me, because I get a pop-up of the fields
available, as I do with any other property.
 
You sometime hear that: "the ! refers to user-defined things and . refers to
Access-defined things." Although that is the standard rule of thumb, it is
not exactly correct. More precisely, the bang (!) serves to separate an
object from the collection which contains it, and the dot (.) serves to
separate one level of the DAO hierarchy from another.

The dot isn't limited to use in DAO, however, which may be indirectly
implied by that statement.

It is also used to seperate objects from their properties, such as
txtTextbox1.Visible


-D
 
Hi Jaroslaw,

I think Roger covers it pretty well. I read his explanation when I was
trying to figure this out myself.

Specific to your question, to further differentiate the dot and bang
operators:
Your example of me.fld1 vs. me!fld1 gives you the same result, which may
suggest that the dot and the bang operators are practically the same. But
suppose you have a control in a form, say an unbound textbox, called Count
(note that Count is also a property of a form, it gives you the number of
controls in the form), then Me.Count and Ne!Count will give you different
results. Me.Count gives you the number of controls in the form whereas
Me!Count gives you the value of your unbound textbox.

So when a form has a property and a control with the same name, then the dot
and the bang operators can be used to differentiate between a form property
and a form control. This is also why it's not a good idea to name a control
within an object the same as a property of that object. It's easy to confuse
the two.


HTH,
Immanuel Sibero
 
Back
Top