access report

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?
 
D

Duane Hookom

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") ))
 
J

John Spencer

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

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