Dcount Help. Returns a 0

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello.

I am trying to count the number of A's in a report

ElementClass is my field contining the letters.

=DCount("[Elementclass]","tbl_ElementClass","[ElementClass] = 'A' ")

It keeps returning a 0 when there are 2 A's n the particular report.

Any help would be appreciated.

Thanks
 
Forgot to add. My information in the report is generated from a qry called
"ALL" so I can filter using a parameter. I tried "ALL" in place of
tbl_ElementClass and recieved an #ERROR message.
 
You should avoid using D...() functions in the report. Try add a text box to
the Report or Group Header or Footer section with a control source like:

=Sum(Abs([ElementClass] ="A"))
 
Thank you very much. It works!. What is sum ABS mean?

Duane Hookom said:
You should avoid using D...() functions in the report. Try add a text box to
the Report or Group Header or Footer section with a control source like:

=Sum(Abs([ElementClass] ="A"))

--
Duane Hookom
MS Access MVP
--

K said:
Hello.

I am trying to count the number of A's in a report

ElementClass is my field contining the letters.

=DCount("[Elementclass]","tbl_ElementClass","[ElementClass] = 'A' ")

It keeps returning a 0 when there are 2 A's n the particular report.

Any help would be appreciated.

Thanks
 
Abs() returns the absolute value of an expression. If the expression is a
true/false statement, the value is -1 or 0. The Abs(-1) = 1. Therefore, you
can Sum(1) to get the "count" of records where the expression is true.

--
Duane Hookom
MS Access MVP
--

K said:
Thank you very much. It works!. What is sum ABS mean?

Duane Hookom said:
You should avoid using D...() functions in the report. Try add a text box
to
the Report or Group Header or Footer section with a control source like:

=Sum(Abs([ElementClass] ="A"))

--
Duane Hookom
MS Access MVP
--

K said:
Hello.

I am trying to count the number of A's in a report

ElementClass is my field contining the letters.

=DCount("[Elementclass]","tbl_ElementClass","[ElementClass] = 'A' ")

It keeps returning a 0 when there are 2 A's n the particular report.

Any help would be appreciated.

Thanks
 
This works great for what I'm trying to do also. But, I need to set more
criteria, For
example: [pv10] = 9 or 10 AND [location] = "US"

I tried this several ways but can't get it to work.. can you help me please??

Duane Hookom said:
You should avoid using D...() functions in the report. Try add a text box to
the Report or Group Header or Footer section with a control source like:

=Sum(Abs([ElementClass] ="A"))

--
Duane Hookom
MS Access MVP
--

K said:
Hello.

I am trying to count the number of A's in a report

ElementClass is my field contining the letters.

=DCount("[Elementclass]","tbl_ElementClass","[ElementClass] = 'A' ")

It keeps returning a 0 when there are 2 A's n the particular report.

Any help would be appreciated.

Thanks
 
I am not sure what you are trying to do. If those are seperate fields in a
query then the Query should Automatically filter it for you for the report,
Then use the function to count the number of 9s and 10s as well as the number
of "US's"

In the query create Field Location_2:IIF([Location]="US","US",0)



Tess said:
This works great for what I'm trying to do also. But, I need to set more
criteria, For
example: [pv10] = 9 or 10 AND [location] = "US"

I tried this several ways but can't get it to work.. can you help me please??

Duane Hookom said:
You should avoid using D...() functions in the report. Try add a text box to
the Report or Group Header or Footer section with a control source like:

=Sum(Abs([ElementClass] ="A"))

--
Duane Hookom
MS Access MVP
--

K said:
Hello.

I am trying to count the number of A's in a report

ElementClass is my field contining the letters.

=DCount("[Elementclass]","tbl_ElementClass","[ElementClass] = 'A' ")

It keeps returning a 0 when there are 2 A's n the particular report.

Any help would be appreciated.

Thanks
 
This works great for what I'm trying to do also. But, I need to set more
criteria, For
example: [pv10] = 9 or 10 AND [location] = "US"

I tried this several ways but can't get it to work.. can you help me please??

Duane Hookom said:
You should avoid using D...() functions in the report. Try add a text box to
the Report or Group Header or Footer section with a control source like:

=Sum(Abs([ElementClass] ="A"))

--
Duane Hookom
MS Access MVP
--

K said:
Hello.

I am trying to count the number of A's in a report

ElementClass is my field contining the letters.

=DCount("[Elementclass]","tbl_ElementClass","[ElementClass] = 'A' ")

It keeps returning a 0 when there are 2 A's n the particular report.

Any help would be appreciated.

Thanks

regarding: [pv10] = 9 or 10 AND [location] = "US"
Your example above is ambiguous and can be logically interpreted
several different ways.

([Pv10]= 9 Or [Pv10] = 10) And [location] = "US"
or
[Pv10]= 9 Or ([Pv10] = 10 And [location] = "US")

will give different results.
In any event, you must repeat the criteria field for both conditions.
 
Back
Top