Dcount question

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
 
R

RonaldoOneNil

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

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

brucedodds2

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.
 
W

wal50

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
 
D

Duane Hookom

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.
 
J

Jeff Boyce

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.
 
J

Jeff Boyce

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Access Dcount (multiple criteria) 3
Access MS Access DCount function problem 0
Dcount Question! 2
DCount Rookie Question 2
Dcount Problem 2
Dcount Problem 2
dcount question! 4
Dcount the values 0

Top