access report

  • Thread starter Thread starter LP
  • Start date Start date
L

LP

How can I retrieve the count of records of different names from a single
field with the DCount function?
I can retrieve from a field such as [ethnicity] the number of say, Irish
using in control source =DCount ("[Ethnicity]","qryX","[Ethnicity]='Irish'
"), which works fine. But if I need the count of Irish and also the
Canadians, using =DCount ("[Ethnicity]","qryX","[Ethnicity]='Irish' AND
'Canadians' ") does not pick up the second entry, ie Canadians. Can anyone
help?
 
Try:
=DCount ("[Ethnicity]","qryX","[Ethnicity] IN ('Irish' ,'Canadians') ")
If your report contains the same records as "qryX" then you don't need
DCount(). Use a control source like:
=Sum(Abs( [Ethnicity] IN ("Irish" ,"Canadians") ))
 
Perhaps what you are looking for is

DCount ("[Ethnicity]","qryX","[Ethnicity]='Irish' OR [Ethnicity]
='Canadians' ")

You MUST repeat the field name, although you can use the shorthand version
if you want one value or another or even another

DCount ("[Ethnicity]","qryX","[Ethnicity] IN ('Irish', 'Canadians',
'Lithuanians') ")
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
Back
Top