By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,162 Members | 1,024 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,162 IT Pros & Developers. It's quick & easy.

Dot or a bang?

P: n/a
MLH
?DCount("[tblCorrespondence]![VehicleJobID]", "qryAOLsNeed2Print")
- OR -
?DCount("[tblCorrespondence].[VehicleJobID]", "qryAOLsNeed2Print")

Both syntaxes return the correct answer for me. But I'm wondering if
one is more suitable than the other for some reason. I'm using A97.
May 23 '06 #1
Share this Question
Share on Google+
10 Replies


P: n/a
MLH <CR**@NorthState.net> wrote in
news:3p********************************@4ax.com:
?DCount("[tblCorrespondence]![VehicleJobID]",
"qryAOLsNeed2Print")
- OR -
?DCount("[tblCorrespondence].[VehicleJobID]",
"qryAOLsNeed2Print")

Both syntaxes return the correct answer for me. But I'm
wondering if one is more suitable than the other for some
reason. I'm using A97.

the bang is the syntactically correct way. Access allows several
errors of syntax, most of the time. You must use a bang to refer
to a field name in a recordset DAOrs.LastName will return an
error, DAOrs!Lastname will return the value of that field.

Personally, I tend to think more highly of people who say, "Is
this not the correct method?" than those would growl "Ai'nt this
rite?" :-)
--
Bob Quintal

PA is y I've altered my email address.
May 23 '06 #2

P: n/a
MLH
<snip>
the bang is the syntactically correct way. Access allows several
errors of syntax, most of the time. You must use a bang to refer
to a field name in a recordset DAOrs.LastName will return an
error, DAOrs!Lastname will return the value of that field. Many thx. I think I'll stick with the syntactically correct way.

Personally, I tend to think more highly of people who say, "Is
this not the correct method?" than those would growl "Ai'nt this
rite?" :-)

I'm glad I didn't growl.
May 24 '06 #3

P: n/a
The dot is the syntactically correct way. Access allows several
syntax variations, most of the time. But by definition you should
use a dot to refer to a field name in SQL, and you might as well
get used to it.

In Access and DAO, TblName!FieldName will return the same value,
but if you open the query in design view, access will display it
as "Expr1: TblName!FieldName". That is, Access understands what
you want, but it's been interpreted as an expression, rather than
as ordinary SQL.

(david)

PS: Personally, I tend to think more highly of people who say,
"It's a machine: I accept that it's behaviour is not morally
determined"


"MLH" <CR**@NorthState.net> wrote in message
news:3p********************************@4ax.com...
?DCount("[tblCorrespondence]![VehicleJobID]", "qryAOLsNeed2Print")
- OR -
?DCount("[tblCorrespondence].[VehicleJobID]", "qryAOLsNeed2Print")

Both syntaxes return the correct answer for me. But I'm wondering if
one is more suitable than the other for some reason. I'm using A97.

May 24 '06 #4

P: n/a
MLH
OK. 2 differing opinions here. Is there some A97 HELP
blurb that supports either opinion?
May 24 '06 #5

P: n/a
A bang (!) is used where what follows is a member of a collection. A dot (.)
is used where what follows is a property or method of the preceding object.
Strictly adhering to this, your code will always work. In some cases
however, what follows may be a member of a collection or a property making
the Bang(!) or Dot(.) appropriate. In these cases, there is an advantage to
using the Dot(.) as it makes the "intellisense" dropdown lists available
where the Bang(!) would not. The disadvantage is that you got to know when
to hold them and know when to fold them. The Dot (.) does not universally
work. As far as performance is concerned, there is no noticeable difference
one way or another.
--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
Over 1175 users have come to me from the newsgroups requesting help
re******@pcdatasheet.com

"MLH" <CR**@NorthState.net> wrote in message
news:nv********************************@4ax.com...
OK. 2 differing opinions here. Is there some A97 HELP
blurb that supports either opinion?

May 26 '06 #6

P: n/a
* PC Datasheet:
A bang (!) is used where what follows is a member of a collection. A dot (.)
is used where what follows is a property or method of the preceding object.
Strictly adhering to this, your code will always work. In some cases
however, what follows may be a member of a collection or a property making
the Bang(!) or Dot(.) appropriate. In these cases, there is an advantage to
using the Dot(.) as it makes the "intellisense" dropdown lists available
where the Bang(!) would not. The disadvantage is that you got to know when
to hold them and know when to fold them. The Dot (.) does not universally
work. As far as performance is concerned, there is no noticeable difference
one way or another.

--
To anyone reading this thread:

It is commonly accepted that these newsgroups are for free
exchange of information. Please be aware that PC Datasheet
is a notorious job hunter. If you are considering doing
business with him then I suggest that you take a look at
the link below first.

http://home.tiscali.nl/arracom/whoissteve.html

Randy Harris
May 26 '06 #7

P: n/a
A Table, Recordset has a collection of fields as a property. Each item
in the fields collection is accessible by index, name or ordinal.
The use of the bang conceals this, by short-circuiting

recordset.fields(index).value
to
recordset!index

I cannot think that the latter is "the syntactically correct way". I
have not used a bang for many years. I think this makes my code clearer
and less prone to error.

IMO the best way (a la Dimitri Furman) to deal with any property of a
field is to declare and intialize a reference to the specific field:
Dim f as DAO/ADO.Field
..
..
..
Set f = r.Fields("Watermelon")
..
..
..
Debug.Print f.Value

Previous tests in CDMA have shown that for repeated reference this is
the fastest way.

May 26 '06 #8

P: n/a
Un this case, we were looking at the first parameter
(field identifier) for a domain function. There is no DAO
or Access recordset or collection.

Domain Functions take SQL strings as parameters.

So the presumption is that JET SQL syntax should be used.

Which is
databasename.tablename.fieldname
or
[databasename].[tablename].[fieldname]

The Jet SQL expression evaluator will also accept
expressions of the form:
tablename!fieldname
or
(tablename!fieldname)
or
(1*(0+tablename!fieldname)) as n

as
v = dcount("(1*(0+tablename!fieldname)) as n","tablename")

Using an expression instead of a fieldname in your SQL
prevents some optimisations, but is generally irrelevant.
However, even more than in VB, it wouldn't normally be
considered good practice.

(david)

"Lyle Fairfield" <ly***********@aim.com> wrote in message
news:11**********************@j33g2000cwa.googlegr oups.com...
A Table, Recordset has a collection of fields as a property. Each item
in the fields collection is accessible by index, name or ordinal.
The use of the bang conceals this, by short-circuiting

recordset.fields(index).value
to
recordset!index

I cannot think that the latter is "the syntactically correct way". I
have not used a bang for many years. I think this makes my code clearer
and less prone to error.

IMO the best way (a la Dimitri Furman) to deal with any property of a
field is to declare and intialize a reference to the specific field:
Dim f as DAO/ADO.Field
.
.
.
Set f = r.Fields("Watermelon")
.
.
.
Debug.Print f.Value

Previous tests in CDMA have shown that for repeated reference this is
the fastest way.

May 27 '06 #9

P: n/a
I was responding to this assertion: "You must use a bang to refer
to a field name in a recordset DAOrs.LastName will return an
error, DAOrs!Lastname will return the value of that field."

Upon re-reading I can see this was beyond the original example.

I do not use Domain Aggregate Functions. The issue of the expression
went right by me.

May 27 '06 #10

P: n/a
IIRC for A97 and before Microsoft said you should use the bang, from A2k
onwards they said use the dot.

Pragmatically, if it gives the same result don't worry about it.

Personally I would use the dot as this is the syntax in SQL Server and you
might as well get used to using it in case you ever switch over.
..

--

Terry Kreft
"MLH" <CR**@NorthState.net> wrote in message
news:3p********************************@4ax.com...
?DCount("[tblCorrespondence]![VehicleJobID]", "qryAOLsNeed2Print")
- OR -
?DCount("[tblCorrespondence].[VehicleJobID]", "qryAOLsNeed2Print")

Both syntaxes return the correct answer for me. But I'm wondering if
one is more suitable than the other for some reason. I'm using A97.

May 28 '06 #11

This discussion thread is closed

Replies have been disabled for this discussion.