Using DCount to count certain fields in a table

gigifarrow
gigifarrow used Ask the Experts™
on
I have a tabel that has a field called, DIV. In those fields are name of companies.
I need the total of certain companies that are in the DIV field. I am using an unbound field to put this information in.  


So what Im trying to say is look in this table under div and find 190-HBCT and count how many times it appears. Then divide that number by 20 to get the total percentage completed by that unit.

=DCount("DIV","tblMODHistory","190-HBCT=-1")/20
=DCount("DIV","tblMODHistory","1CAV=-1")/20
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Are you saying that your DIV field has data such as 190-HCBT and 1CAV?  If so then these should work:

=DCount("*","tblMODHistory","190-HBCT")/20
=DCount("*","tblMODHistory","1CAV")/20

Commented:
Is '190-HBCT' a field?  if so, try enclosing it and also 'DIV' in brackets.
=DCount("[DIV]","tblMODHistory","[190-HBCT]=-1")/20
Nerd
Most Valuable Expert 2012
Top Expert 2013
Commented:
Try this - assuming that Div is a fieldname and that you are trying to count ocurrences of "190-HBCT" and "1Cav" under the Div column in your table:


=DCount("*","tblMODHistory","[Div] = '190-HBCT'")/20
=DCount("*","tblMODHistory","[Div]='1CAV'")/20
Oops, as mbizup's answer shows, I forgot part of the argument in my response.  Looks like either his answer or trbaze's would work for you depending on how you have your fields set up.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial