Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Odd Syntax that seems to work...

Status
Not open for further replies.

lameid

Programmer
Joined
Jan 31, 2001
Messages
4,212
Location
US
I am contracting and I've seen quite a bit of odd fully qualified field references. It seems to work but rubs me the wrong way to look at it...

Code:
[Table name!Field Name]

I of course expect to see...

Code:
[Table name].[Field Name]

The exclamation point does not bother me too much as I expect that fields is the default collection, but the bracketing is what is throwing me. Since the peculiar syntax is not default SQL syntax, I have been 'fixing' it as I run into it.

Any thoughts on why it works? It is more of a curiosity to me at this point than anything.
 
There are so many discussions on "Bang Versus Period operator"


The dot operator references a member of the object's class. The ! operator
references a named member of the object's default collection. Sometimes, a
property (but never a method) may be accessible both ways, but only because
the class both exposes the property as a member of the class and provides it
as a member of the default collection. Dot references are always resolved at
compile time if possible, and ! references are never resolved until run-time.


In the case of an Access form, Access creates a hidden class member for each
control in the controls collection which is why you can reference fields using
the dot operator. The same cannot be said in the case of, for instance, a
recordset in which the defailt collection is Fields, and the only items
accessible through that colleciton are field objects.


Incidentally, Access failing to keep the virtual field members of a form in
sync with the controls on the form is a major cause of Access project
corruption, so we've found it to be safer to always use ! in these cases, even
though auto-sense does not work as well that way, and some errors cannot be
caught at compile-time.

Zameer Abdulla
 
Like I said it is the braketing that is more suprising to me than the exclamation point but that is still good information about compile time.

And to be explicit rather than implicit, I am seeing this in queries.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top