Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Exclamation Mark / Square Brackets / Dots

Discussion in 'Information Technology' started by Fabio, Jul 28, 2006.

  1. Fabio

    Fabio
    Expand Collapse
    Guest

    Hello There,

    I wonder if someone could tell me what is the difference between "!" and a
    "." ?
    As I am new in Access I don't know what is the difference if I enter the
    following as a Criteria for a query:
    [forms].[form_A]. (...) and
    [forms]![form_A]! (...)
    --
    Many Thanks
    Fabio
     
  2. Loading...


  3. Dirk Goldgar

    Dirk Goldgar
    Expand Collapse
    Guest

    "Fabio" <Fabio@discussions.microsoft.com> wrote in message
    news:140C4B0D-7ACE-41AB-940F-14FDEC474178@microsoft.com
    > Hello There,
    >
    > I wonder if someone could tell me what is the difference between "!"
    > and a "." ?
    > As I am new in Access I don't know what is the difference if I enter
    > the following as a Criteria for a query:
    > [forms].[form_A]. (...) and
    > [forms]![form_A]! (...)


    Below is my standard write-up on the matter. Google Groups will turn up
    a lot more discussion, if you need it.

    --------- BANG (!) vs. DOT (.) ----------
    It's not so much a question of one or the other being "proper syntax",
    but that they mean different things that nevertheless almost always give
    the same result. As I understand it, the bang (!) notation specifically
    denotes that what follows is a member of a collection; in this case, a
    member of the form object's default collection, the Controls collection.
    The dot (.) notation denotes that what follows is a property or method
    of the preceding object. That would logically make the bang notation
    "proper" and the dot notation improper.

    But wait. Wherever possible, Access makes the controls on a form and
    the fields in its recordsource all available as properties of the form.
    It also makes the fields of the recordsource available via the bang
    notation. I'm not sure exactly how it does this; maybe if a name is
    not found in the Controls collection it checks the Fields collection of
    the form's recordset as a fallback position. So for most practical
    purposes Me!ControlName and Me.ControlName evaluate to the same thing,
    and the timing tests I've seen suggest that there is little to choose
    between them as far as execution efficiency is concerned. I seem to
    recall that there is a very slight difference, but I can't remember
    which way the advantage lies, and it's not much. There's a coding-time
    advantage, however, to using the dot notation, as it makes the
    "intellisense" dropdown lists available. That's a strong argument for
    using the dot notation, in my book.

    But wait again! I said above that Access makes the controls available
    as properties "wherever possible". There are cases where it can't do
    that. Specifically, it can't do it when there is already a property of
    the same name as the control in question. For example, if your form
    "Form1" has a control or a field foolishly named "Name", currently
    displaying the value "John Doe", then executing this statement in the
    form's code module:

    Debug.Print Me!Name, Me.Name

    will print

    John Doe Form1

    in the Immediate Window. So you must be careful not to use any reserved
    words or built-in properties as names for your controls, if you want to
    use the dot notation to refer to them. But then, you should avoid doing
    that anyway, as it tends in general to confuse poor Access.

    --
    Dirk Goldgar, MS Access MVP
    www.datagnostics.com

    (please reply to the newsgroup)
     
  4. Fabio

    Fabio
    Expand Collapse
    Guest

    Hi Dirk,

    Thank you very much for the clear and detailed explanation on Bang vs Dot. I
    was very uncomfortable with the idea of starting developing syntaxes that I
    wasn't sure whether they were "safe".
    --
    Regards
    Fabio

    "Dirk Goldgar" wrote:

    > "Fabio" <Fabio@discussions.microsoft.com> wrote in message
    > news:140C4B0D-7ACE-41AB-940F-14FDEC474178@microsoft.com
    > > Hello There,
    > >
    > > I wonder if someone could tell me what is the difference between "!"
    > > and a "." ?
    > > As I am new in Access I don't know what is the difference if I enter
    > > the following as a Criteria for a query:
    > > [forms].[form_A]. (...) and
    > > [forms]![form_A]! (...)

    >
    > Below is my standard write-up on the matter. Google Groups will turn up
    > a lot more discussion, if you need it.
    >
    > --------- BANG (!) vs. DOT (.) ----------
    > It's not so much a question of one or the other being "proper syntax",
    > but that they mean different things that nevertheless almost always give
    > the same result. As I understand it, the bang (!) notation specifically
    > denotes that what follows is a member of a collection; in this case, a
    > member of the form object's default collection, the Controls collection.
    > The dot (.) notation denotes that what follows is a property or method
    > of the preceding object. That would logically make the bang notation
    > "proper" and the dot notation improper.
    >
    > But wait. Wherever possible, Access makes the controls on a form and
    > the fields in its recordsource all available as properties of the form.
    > It also makes the fields of the recordsource available via the bang
    > notation. I'm not sure exactly how it does this; maybe if a name is
    > not found in the Controls collection it checks the Fields collection of
    > the form's recordset as a fallback position. So for most practical
    > purposes Me!ControlName and Me.ControlName evaluate to the same thing,
    > and the timing tests I've seen suggest that there is little to choose
    > between them as far as execution efficiency is concerned. I seem to
    > recall that there is a very slight difference, but I can't remember
    > which way the advantage lies, and it's not much. There's a coding-time
    > advantage, however, to using the dot notation, as it makes the
    > "intellisense" dropdown lists available. That's a strong argument for
    > using the dot notation, in my book.
    >
    > But wait again! I said above that Access makes the controls available
    > as properties "wherever possible". There are cases where it can't do
    > that. Specifically, it can't do it when there is already a property of
    > the same name as the control in question. For example, if your form
    > "Form1" has a control or a field foolishly named "Name", currently
    > displaying the value "John Doe", then executing this statement in the
    > form's code module:
    >
    > Debug.Print Me!Name, Me.Name
    >
    > will print
    >
    > John Doe Form1
    >
    > in the Immediate Window. So you must be careful not to use any reserved
    > words or built-in properties as names for your controls, if you want to
    > use the dot notation to refer to them. But then, you should avoid doing
    > that anyway, as it tends in general to confuse poor Access.
    >
    > --
    > Dirk Goldgar, MS Access MVP
    > www.datagnostics.com
    >
    > (please reply to the newsgroup)
    >
    >
    >
     

Share This Page