Results 1 to 6 of 6
  1. #1
    Hossein's Avatar
    Hossein is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Oct 2018
    Posts
    24

    Lightbulb What is difference between (Bang) and Dot ? VBA

    Hi guys

    I have some simple question

    1) What is difference between (Bang) and dot ? for example Me!Combobox vs Me.Combobox

    2) What is difference between Me.Combobox vs Me.Combobox.value vs Combobox

    3) What is difference between [Forms]![SampleForm]![Combobox] vs Me!Combobox

    4) Do you have good source as a book or video course training in order to VBA in access and writing query ? (Related to query i am using access query wizard or some times, SQL assistant as a addins software that is great)

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    1. Dot provokes VBA intellisense popup tips

    2. Nothing because Value is default property for data controls. Omitting explicit reference to form will still work but won't get intellisense.

    3. If the first syntax you show is behind the referenced form, then there is no difference. The first syntax can be used in queries. Me. and Me! can only be used in VBA

    4. I am sure there are many but I don't actually have one. This question has been asked many times. Here is one https://www.accessforums.net/showthread.php?t=55379
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Uncle Gizmo is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Oct 2016
    Posts
    26
    Quote Originally Posted by June7 View Post
    2. Nothing because Value is default property for data controls. [/URL]
    "Value" is indeed the default property and you seldom need to use it, however there is one area I have discovered that you do need to use it see my post here:-

    https://www.niftyaccess.com/tempvars-value-error/

    Sent from my Pixel 3a using Tapatalk

  4. #4
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,424
    there is more to 1 then that.
    Bang provides late bound access to the default member of the object that precedes it by passing the name value of what follows it. If we use Me as an example, the default member of Me is the controls collection, thus Me!txtDept will work IF txtDept is a control on the form referenced by Me. Me.txtDept is an explicit reference to the parent object and its child member and is not late bound. Therefore, if we misspell the control name txtbox, Me.tttextbox will be caught when you compile the code or attempt to run it. Me!tttextbox will not raise an error until there is an attempt to execute that line of code. I NEVER use Me!

    That is not a complete treatise on the subject; e.g. I have not thought about why ! is the correct (only?) method when it comes to certain recordset references such as when referring to a recordset field by name. That does not include referencing the recordset field via the Fields collection.

    Regarding 3, it should then be apparent by the forgoing that I would not use [Forms]![SampleForm]![Combobox] either.
    It would be [Forms]![SampleForm].[Combobox]
    So why not [Forms].[SampleForm].[Combobox]? I don't know. It is just one of those things that you (I) learn is the correct syntax. Perhaps a form by name is not the default member of Forms collection - I never bothered to figure that one out either.
    Last edited by Micron; 07-05-2019 at 04:09 PM. Reason: clarification
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,939
    have not thought about why ! is the correct (only?) method when it comes to certain recordset references such as when referring to a recordset field by name
    I think you will find that by definition the fields are latebound - the recordset is created during execution and is effectively a collection. Same for forms!myform - myform is only added to the forms collection when opened. Otherwise your code would fail compilation unless the referenced form was open at that time - clearly not feasible for an entire app - all forms referenced by code would need to be open.

    However the properties and methods of the collection (be it recordset, forms, controls etc are made available when the object is defined. In vba if you enter 'forms.' then the intellisense will show the properties and methods available to the forms collection.

  6. #6
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,424
    I think you will find that by definition the fields are latebound
    That seems logical.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Difference query
    By Kundan in forum Queries
    Replies: 3
    Last Post: 11-25-2018, 10:11 PM
  2. What is this difference between these?
    By Lou_Reed in forum Access
    Replies: 4
    Last Post: 03-31-2017, 10:43 AM
  3. SQL Subselect difference between
    By NCepeda in forum Queries
    Replies: 3
    Last Post: 02-26-2016, 06:52 PM
  4. Difference between the value from two different date
    By mahmud1180 in forum Programming
    Replies: 2
    Last Post: 10-02-2014, 08:40 AM
  5. Get difference of Min and Max
    By nazimscr in forum Queries
    Replies: 1
    Last Post: 07-14-2012, 02:04 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums