dots and bangs- Why bang then?

cogent1

Registered User.
Local time
Today, 10:18
Joined
May 20, 2002
Messages
315
I have recently read in a posting by Pat Hartmann that the dot(.) operator is preferable to the bang(!) in referring to fields in code because it creates early binding and is generally a Jolly Good Thing!
I accept this statement as coming from a competent authority,but it begs the question as to why the bang is there in the first place and why so many books on Access programming don't mention the interchangeability of the two operators?

Should we ban the bang?
 
I beleive the rule-of-thumb is:

dot (.) is for properties
bang (!) is for data fields (such as the recordset in your form.

This is the main reason it is always strongly suggested that your "Controls" have different names then your Recordset fields.

The bang is also a good way to include a field that does not have a Control on your form/report in a calculation.
 
For me, the difference is mainly this:

As a matter of consistency, I use bang as a separator between table and field even sometimes when I really don't need to, particularly if I am also going to use dot on the table to pick up on the table's properties in VBA code.

When I'm in a query grid, it doesn't matter because you don't normally access properties from a query grid. Now, in queries based on SQL that cannot appear in a query grid, I don't think you can get at table properties but then, I've never actually tried that.

In forms and reports it normally doesn't matter because from text boxes, combo boxes, and the like, you don't access properties as recordsources or controlsources. But in the VBA underneath the code, it makes a big difference for readability.

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.

I usually am forgiving of Access when it gives me dot-bang grief, though. After all, it IS a Gates product. So I pity it rather than censure it.
 
Thanks for these clarifications. Since posting my question, I have read in a programming tome that the bang operator is also a JGT, the Jet engine likes it better, it's faster etc. I wonder what's true and ultimately, for the databases I write, whether a microsecond here or there makes any great difference. But it's interesting, so thanks for the input.
 

Users who are viewing this thread

Back
Top Bottom