Dcount Problem

  • Thread starter Thread starter Judy
  • Start date Start date
J

Judy

I know this is an elementary problem but the more I try to fix it the
more confused I get. I need some simple help here. I have searched the
Group for an answer but can't find one so here goes.
-----------------------------------
I have a form that contains a Dcount. I can't seem to get the syntax
correct.

Table name: tblNameList
Field: option1. This field only contains one of two records both
currency. It either contains $0.00 or $15.00.

I am trying to count the number of times that $15.00 appears in the
field option1.

The Dcount I am trying is this but I get an error.

=DCount([tblNameList]![option1],"tblNameList",[tblNameList]![option1]
="$15.00")

What am I doing wrong? Any help would be appreciated.
Thanks in advance.
 
I know this is an elementary problem but the more I try to fix it the
more confused I get. I need some simple help here. I have searched the
Group for an answer but can't find one so here goes.
-----------------------------------
I have a form that contains a Dcount. I can't seem to get the syntax
correct.

Table name: tblNameList
Field: option1. This field only contains one of two records both
currency. It either contains $0.00 or $15.00.

I am trying to count the number of times that $15.00 appears in the
field option1.

The Dcount I am trying is this but I get an error.

=DCount([tblNameList]![option1],"tblNameList",[tblNameList]![option1]
="$15.00")

What am I doing wrong? Any help would be appreciated.
Thanks in advance.

Several things.

First off, DCount doesn't count fields - it counts the number of *records* in
the table or query which match the (optional) critirion in the third argument.

Secondly, all three arguments of DCount must be Strings. The first is what
you'll be counting; it's simplest just to use "*" in a case like this, because
you're just counting records. The second argument is the name of a Table or a
Query in which you're counting records, again as a text string. The third
argument is a valid SQL WHERE clause, without the word WHERE, specifying which
records you want to count.

The exact syntax depends on the Datatype of the field named Option1. If the
field is a Currency or Number, then use

=DCount("*", "tblNameList", "[Option1] = 15")

If the field is Text and actually contains the literal text string "$15.00"
then use

=DCount("*", "tblNameList", "[Option1] = '$15.00'")

using ' as a delimeter for the string criterion.
 
Back
Top