DCount

J

JenS

I have a field called "Status" with the numbers 0, 1, and 2. I want get a
count of each of these numbers in a report. I have created a text box for
each occurance and have entered the following formula to count the number of
0's but it is not working. =DCount("[Status]",[Status]=0) What am I doing
wrong?
 
K

KARL DEWEY

If your Status field is text datatype then use this --
=DCount("[Status]",[Status]="0")
 
J

JenS

The Status field is numeric and contains only the numbers 0, 1, and 2. I
have tried numerous variations of my formula, and nothing seems to work.
--
JenS


KARL DEWEY said:
If your Status field is text datatype then use this --
=DCount("[Status]",[Status]="0")
--
KARL DEWEY
Build a little - Test a little


JenS said:
I have a field called "Status" with the numbers 0, 1, and 2. I want get a
count of each of these numbers in a report. I have created a text box for
each occurance and have entered the following formula to count the number of
0's but it is not working. =DCount("[Status]",[Status]=0) What am I doing
wrong?
 
D

Douglas J. Steele

Assuming that Status is a numeric field:

DCount("*", "[Status]", "[Status]=0")

If it's a text field:

DCount("*", "[Status]", "[Status]='0'")
 
J

John W. Vinson

I have a field called "Status" with the numbers 0, 1, and 2. I want get a
count of each of these numbers in a report. I have created a text box for
each occurance and have entered the following formula to count the number of
0's but it is not working. =DCount("[Status]",[Status]=0) What am I doing
wrong?

Take a look at the online help for DCount. DCount has *THREE* operands, you're
giving it only two. The second operand is the name of the table or the query
containing the field. The third operation must be a Text String evaluating to
a valid SQL WHERE clause - you're using the expression, not a text string.

In addition, DCount doesn't count field values, it counts records. You can
just use "*" as the field to count all records which meet the criteria. Try:

=DCount("*", "[yourtablename]", "[Status] = 0")

to count all Status=0 records in yourtablename.

If you want to count the number of records in a query, use the query name
instead of yourtablename.
 

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

Top