Results 1 to 9 of 9
  1. #1
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926

    Unanswered: Syntax - dot (.) versus bang (!)

    To anyone,

    Did I miss something with one of the versions of MSAccess or does . still represent the field and ! represents the value? (or me.myfieldname.value) I'm constantly seeing posts where . is used (ie. me.myfieldname) to represent the value. Although me.myfieldname 'usually' works, I've always used ! (from the old MSAccess days where MSAccess was NOT forgiving if you used . versus !)

    Someone please correct me or explain to me why everyone seems to want to use me.MyFieldname to represent the value of the field. (even though I know using the . will expand the options for syntax.)

    ie.

    me.MyFieldName <- represents the field/control itself
    versus
    me!MyFieldName or me.MyFieldName.Value <- represents the VALUE of the field/control


    It's one of those things that bugs me when I constantly see the dot used but maybe something has changed with newer versions of MSAccess that I missed learning along the way.

    Could someone please confirm the proper way to represent the VALUE of the field? (like I said, for some reason it bugs me when I see this kind of syntax used.) But then again, so does seeing fieldnames called: This is my field name with many spaces (versus: ThisIsMyFieldNameWithNOSpaces) or fields named: ThisIsMyFieldNameWhereILikeToUse!and# (again, just something that has bugged me when I see this kind of syntax in posts and I don't want to give wrong advice if something has changed with MSAccess over the last 20 years that I wasn't aware of (but maybe it's just my habit of always using ! versus . - again from the old MSAccess 2.0 days.)

    Or maybe I'm just having a bad day.
    Last edited by pkstormy; 04-07-10 at 22:10.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  2. #2
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Update: pbaldy was kind of enough to supply a link in this post: http://www.dbforums.com/6455595-post8.html

    I found some interesting comments about Intellisense and MSAccess (from googling).

    From further research, it seems as though using syntax like me.myfieldname is correct (in certain situations.) I'll still stick with using the bang though - old habits are hard to break but as the saying goes...'you're never too old to learn something new, especially after doing the same thing for 20 years'. (plus I've noticed that syntax such as me.myfieldname sometimes tends to cause issues when upsizing to a newer MSAccess version if incorrectly used.)
    Last edited by pkstormy; 04-07-10 at 22:09.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  3. #3
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    For those interested, here's info from the link pbaldy supplied:

    "The dot gives you early binding and is resolved at compile time, the bang is resolved at runtime.
    In the case of Forms, both controls and fields in the underlying query can be referenced via a dot since they are all in the type library for the form.
    Also in the case of Forms, if you change the underlying query at runtime - dot references to the old query's fields will fail at runtime since update of the Form's type library cannot happen at runtime.
    Because the dot is early bound, IntelliSense happens by default with the dot, not with the bang.
    The dot (since it is early bound) is faster than the bang, but no one runs enough code that uses these items enough for the performance difference to actually matter."

    I would be curious to see what the actual speed difference is using !

    Thanks again Paul for setting my mind at ease.
    Last edited by pkstormy; 04-07-10 at 22:02.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  4. #4
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    For those interested, in my quest on the dot versus bang, I came across this interesting site regarding MSAccess 2010 features (even though it's not specifically related to the original post in this thread.)

    Microsoft Access 2010 new feature overview | Microsoft Office | TechRepublic.com

    Hopefully with 2010, Microsoft has realized that there are still old-time MSAccess developers who detest 2007 and made some 'good' changes this time around.

    I got a copy of MSAccess 2010 and I'm 'almost' ready to give it a try (providing MS didn't move everything around again like in 2007). If only I could spend 10 minutes talking with the developers of MSAccess to let them know what they've done to make 2007 a disaster for those who have been developing with MSAccess for almost 20 some years. Back in 1991, I was tossed a free copy of version 1.0 and had a direct line (via the military) to the actual developers of MSAccess (and would spend hours talking with them daily.) But those were the good old days. Still though, it was nice to give input for version 2.0. I wonder though what group of developers MS was talking to when they developed 2007 (probably the same group of people who wanted Vista.)
    Last edited by pkstormy; 04-07-10 at 22:31.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  5. #5
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Quote Originally Posted by pkstormy View Post
    I would be curious to see what the actual speed difference is using !

    Thanks again Paul for setting my mind at ease.
    No problemo, my friend. I suspect the speed difference is barely measurable.
    Paul

  6. #6
    Join Date
    Mar 2009
    Posts
    5,441
    Provided Answers: 14
    As far as I know, Me!Something does not necessarily references the value of Something, it references the default property of Something (which often is its Value property).
    Have a nice day!

  7. #7
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    I'm not going to read the links yet, I'll just post what I thought was the case and then test myself.

    ! references an item in a collection.
    . references a property of an object.

    The reason you can sometimes mix and match between ! and . is because, for example, each control on a form and report is both an item in a collection and also added to the containing object's properties.

    Semi-interesting side note - one of my colleagues calls the Bang a Pling, which is what it was called in BBC BASIC.

  8. #8
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Oh ok, this appears to broadly support what I thought. It also explains of course why one is early bound and one is late bound - properties are created at design time, collections populated at run time.
    Cleaner Coding: Bang vs. Dot -- It’s time to reconsider an old Access rule. ++ Tags: Code, Microsoft, Microsoft Access, Microsoft Office, Microsoft Windows, Programming, VBA

  9. #9
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    I don't want to dwell on this set of threads and waste others time.


    Out of curiosity, I did however dig out my Developers 2000 handbook for MSAccess (by Sybex), and interestingly noticed the bang was encouraged to be used (as well as in their examples).
    Last edited by pkstormy; 04-08-10 at 21:02.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Posting Permissions

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