Bang and dot? (1 Viewer)

Gasman

Enthusiastic Amateur
Local time
Today, 17:33
Joined
Sep 21, 2011
Messages
14,257
Hi all,


In trying to help out in this thread
https://access-programmers.co.uk/forums/showthread.php?t=299699
I realised that I am still not sure when to use a ! and when to use a .
When one must use a ! and when must use a .
When are they interchangeable?


Could someone please explain in terrms an idiot can understand or point me to a definitive source that will explain it, even to me.?


TIA
 

Gasman

Enthusiastic Amateur
Local time
Today, 17:33
Joined
Sep 21, 2011
Messages
14,257
Thank you Minty
From post 3 of that thread
In VBA, there are cases where you MUST use bang because dot doesn't work. And there are cases where you must use dot because bang doesn't work. Usually having to do with discovery of or enumeration of collections. So of course, there I do what I need to do to make it work.

Yet in my helping thread I changed the query criteria from

[Forms]![Domestic Faults]![sfm1].[Form]![cboDepartment]
to
[Forms].[Domestic Faults].[sfm1].[Form].[cboDepartment]

and it still worked, yet to my mind Forms is a collection?

I only had the . in the first line of code as that was what was shown in a Google search. :D
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 00:33
Joined
May 7, 2009
Messages
19,230
General rule is if it is if it is an intrinsic Member, use Dot. If you add it use the Bang.
 

NauticalGent

Ignore List Poster Boy
Local time
Today, 12:33
Joined
Apr 27, 2015
Messages
6,328
To add to your confusion, this was one of the first threads I read a few years back when I was first pondering this issue.

https://access-programmers.co.uk/forums/showthread.php?t=202806

I am not sure why, but I really enjoy watching the HeavyWeights offering semi-opposing views. It could because I get reassured that there is hope for me and knowledgeable dialogue is beneficial.

Recently, Galaxiom revisited a thread he had participated with some interesting points on this, but I cannot find the @#$& thing now...
 

plog

Banishment Pending
Local time
Today, 11:33
Joined
May 11, 2011
Messages
11,643
Wait. Wait. Wait. Hold everything.

You guys call an exclamation point (!) a bang?

As an american I enjoy mocking your weird terms for things, but even I can't find fault with that. Not only is it cool and actually intuitive, its practical--1 syllable compared to our 5 syllables? Unfortunately, you guys win this one.
 

Galaxiom

Super Moderator
Staff member
Local time
Tomorrow, 02:33
Joined
Jan 20, 2009
Messages
12,851
A lot has been said about dot versus bangs, much of it is wrong. I have contributed some less than precise stuff myself but the following is fairly accurate (given the limitations of time to fully explain it) and can be tested.

Full references use the Collection and Item names.
eg
Code:
Forms("formname").Properties("Propertyname")
Forms("formname").Controls("controlname")

The dot is an Early Bound reference to a member of an object. A member can be a Property, Method or via the defaults, an Item in a collection. A series of defaults chooses which collection has precedence if there is more than one and the complete reference is not spelt out. For a form it is the Controls Collection. (I suspect this default system has changed over different versions of Access.)

Forms.Controls.controlname is abbreviated to Forms.controlname by omitting the default.

Being early bound, dot references are tested during compilation. A reference to property, method or control that does not exist will throw an error during compilation so it is better to use the dot where appropriate.

The bang is shorthand for a Late Bound Reference to the default member of an object. Being Late Bound, any error due to an invalid reference will not be picked up during the compile. Exactly what the default member of an object is depends on the object but Properties and Methods are never the default so the dot must always be used for them.

Forms!controlname will compile even if the there is no control by that name, then error when the line is executed during run time.

"Forms!" or "Forms." is a grey area. Strictly speaking the Forms Collection is empty until a form is loaded, so a bang would be considered more appropriate but that is just academic because VBA doesn't care. In practical terms, a reference to a form in the query designer will only trigger Intellisense if the bang is used (A2010 onwards).

A recordset is a dynamic object, hence Early Bound is an oxymoron when referring to fields in it. Consequently items in the Fields Collection of a recordset must be referred to in shorthand via the bang. The dot will not work. The default member of a recordset is the Fields Collection.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 17:33
Joined
Jul 9, 2003
Messages
16,278
"Bang" might have different meanings in USA / UK...

Just a guess!

Sent from my SM-G925F using Tapatalk
 

Galaxiom

Super Moderator
Staff member
Local time
Tomorrow, 02:33
Joined
Jan 20, 2009
Messages
12,851
Wait. Wait. Wait. Hold everything.

You guys call an exclamation point (!) a bang?

Showing my age here.
What you guys call a "full stop" a "dot"? ;)
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 11:33
Joined
Feb 28, 2001
Messages
27,162
Can't add to Galaxiom's advice on when to use each, but I can verify that the vernacular has included "bang" to represent "!" (exclamation point) ever since I started talking to UNIX programmers and that has been over 30 years ago. I also know that "dot" become popular in web addresses (named AND numbered) a long time ago, again at least 30 years.

For those who wonder why, I'm pedantic and proud of it! So, here's your reasons:

"Bang" is easier and faster to say than "Exclamation Point" and in literature, most of the time when you see the word "Bang" in print (usually to represent gunshots or small explosions) it is followed by an exclamation point anyway.

"Dot" has fewer syllables than "Period" or "Full Stop." But in old USA telegraphy, they DID use the word "STOP" to represent a period. The use of "dot" probably came in with Morse code along with "dash" (as opposed to the longer "minus sign").

People are ALWAYS looking for shorter ways to communicate. Which is why the Navy used to drive me nuts with their frickin' acronyms. For a while I used to be associated with NAVRESINFOSYSOFF (Naval Reserve Information Systems Office) and we couldn't use NRISO at the time because of overlap with some other service group.

But we are no better - we talk about FE and BE files, IP addresses, SMB protocols, etc. So... bang and dot have entered our vernacular, for better or worse.
 

Gasman

Enthusiastic Amateur
Local time
Today, 17:33
Joined
Sep 21, 2011
Messages
14,257
I am just using the terms they appear to be called today?


When I worked for Honeywell Bull we actually called it a shriek? :D

Wait. Wait. Wait. Hold everything.

You guys call an exclamation point (!) a bang?

As an american I enjoy mocking your weird terms for things, but even I can't find fault with that. Not only is it cool and actually intuitive, its practical--1 syllable compared to our 5 syllables? Unfortunately, you guys win this one.
 

Gasman

Enthusiastic Amateur
Local time
Today, 17:33
Joined
Sep 21, 2011
Messages
14,257
Yeh, always made me laugh when you heard of someone called Randy.
:D
"Bang" might have different meanings in USA / UK...

Just a guess!

Sent from my SM-G925F using Tapatalk
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 12:33
Joined
Feb 19, 2002
Messages
43,257
Excellent explanation Galaxiom.

There are a few experts who post a lot of code with Me!fieldname which I correct if I can to Me.fieldname. While technically fieldname is a user defined object and so should be preceded by a bang, in practice, Access adds the columns of the RecordSource to the Report's and form's Fields collection. The reason for using the dot rather than the bang to reference columns of the bound RecordSource is simply - early binding. You want compile errors rather than runtime errors whenever you have reference anomalies. Also, in earlier versions of Access, you didn't get intellisense with the bang but that seems to no longer be the case.
 

isladogs

MVP / VIP
Local time
Today, 17:33
Joined
Jan 14, 2017
Messages
18,211
Forgetting about Access for a second, does anyone in the UK actually use 'exclamation point' rather than 'exclamation mark' when referring to a '!'

And I still prefer hash to octothorpes for '#' (but then my formative years were the 1960s)
 

Mark_

Longboard on the internet
Local time
Today, 09:33
Joined
Sep 12, 2017
Messages
2,111
<- is wondering why Uncle decided to separate the USA & UK with a virgule...

P.S. for laughs, I found out that in some Slavic countries "@" is referred to as "Monkey".
 

NauticalGent

Ignore List Poster Boy
Local time
Today, 12:33
Joined
Apr 27, 2015
Messages
6,328
I see Galaxiom found his post. I remembered it being something on this topic the had not been discussed before (late/early binding) but not not recall it to save my skin.

Glad he found it and re-posted it here.
 

BeeJayEff

Registered User.
Local time
Today, 09:33
Joined
Sep 10, 2013
Messages
198
Forgetting about Access for a second, does anyone in the UK actually use 'exclamation point' rather than 'exclamation mark' when referring to a '!'
I don't think so. What do our transatlantic cousins call a "?" - question point or question mark or query or something else entirely ? And I use shriek rather than bang.
 

Users who are viewing this thread

Top Bottom