Dcount question

  • Thread starter Thread starter wal50
  • Start date Start date
W

wal50

Report is based upon qryBB. I am attempting to count the number of resulting
records that have [Pos] = C. [Name] is unique.

From other threads, I have tried

=DCount([Name],"QryBB",[POS]="C")
=DCount([Name],"QryBB","[POS]='C'")

and several other permutations with no results. Sometimes # Error;
sometimes invalid syntax.

Probably simple but I can't see it.
Thanks in advance for you help.
wal50
 
Dcount's parameters are strings so you need the following (note the
apostrophies around 'C')

=DCount("[Name]","QryBB","[POS]='C'")
 
It's good to avoid using the terms for Access objects and properties
when naming objects. For example, I wouldn't name anything "Name".
You'll find an explanation if you search for "Reserved Words" in Help.

Try calling that column something else.
 
Thnaks Ron. Damn syntax

RonaldoOneNil said:
Dcount's parameters are strings so you need the following (note the
apostrophies around 'C')

=DCount("[Name]","QryBB","[POS]='C'")

wal50 said:
Report is based upon qryBB. I am attempting to count the number of resulting
records that have [Pos] = C. [Name] is unique.

From other threads, I have tried

=DCount([Name],"QryBB",[POS]="C")
=DCount([Name],"QryBB","[POS]='C'")

and several other permutations with no results. Sometimes # Error;
sometimes invalid syntax.

Probably simple but I can't see it.
Thanks in advance for you help.
wal50
 
Since the report is based on the same query as you are counting, the most
efficient solution is to use a text box with a control source of:
=Sum(Abs(POS = "C"))
DCount() opens another recordset which takes more resources. Also, if you
open the report with a WHERE CONDITION, the DCount() of C records might not
match the number of C records in the report.
 
I may not be remembering accurately, but I thought that the DCount()
function would choke if it found none (i.e., returned a Null set)...

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
I bet you're right!

Jeff

(the memory is the ... ? ... thing to go)

J_Goddard via AccessMonster.com said:
Hi Jeff -

I think you are referring to DLookup, which does return a Null when there
are
no matching records. DCount would not be of much use if it could not
return
a 0 when no records met the criteria!

John



Jeff said:
I may not be remembering accurately, but I thought that the DCount()
function would choke if it found none (i.e., returned a Null set)...

Regards

Jeff Boyce
Microsoft Access MVP
Report is based upon qryBB. I am attempting to count the number of
resulting
[quoted text clipped - 11 lines]
Thanks in advance for you help.
wal50

--
John Goddard
Ottawa, ON Canada
jrgoddard at cyberus dot ca

Message posted via AccessMonster.com
 
Back
Top