Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Mar 2009
    Location
    Hong Kong
    Posts
    359
    Thanks
    0
    Thanked 0 Times in 0 Posts
    How to quality objects with ! (exclamation) and . (period)?
    In particular, when should ! (exclamation be used?
    Thanks.
    Armstrong

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    The bang or exclamation mark ! is used to indicate a member of a collection. For example Forms!frmMain specifies frmMain as a member of the Forms collection.

    The period . is used to indicate a property or method of an object. For example Forms!frmMain.Caption is the Caption property of the form frmMain.

    Controls on a form are both members of the form's Controls collection and properties of the form. Since Controls is the default property of the form, the following are equivalent:

    Forms!frmMain.Controls!txtLast
    Forms!frmMain!txtLast
    Forms!frmMain.txtLast

  3. #3
    3 Star Lounger
    Join Date
    Mar 2009
    Location
    Hong Kong
    Posts
    359
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='HansV' post='780246' date='17-Jun-2009 14:18']Controls on a form are both members of the form's Controls collection and properties of the form. Since Controls is the default property of the form, the following are equivalent:

    Forms!frmMain.Controls!txtLast
    Forms!frmMain!txtLast
    Forms!frmMain.txtLast[/quote]
    HansV,
    Thanks to your crystal clear enlightenment, now I realize the period (.) is meant for property/method.
    It's the latter I was confused. Different authors of different books use ! and . arbitrarily. It turns out to be they're equivalent. That's interesting.
    Thanks for your help.
    Armstrong

  4. #4
    4 Star Lounger SteveH's Avatar
    Join Date
    Jan 2001
    Location
    Chelsea, Gtr London, United Kingdom
    Posts
    587
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If you use . when typing code you will get the Intellisense - this will save you from mispelling a control name. It also means that if you rename a control on the form, the code will not compile until you change all references to that renamed control in code.
    Steve H
    IT Lecturer/Access Developer
    O2K SR3/O2010; Win7Pro

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •