Search code examples
vbavb6dcount

Dcount function --- assistance with criteria


I'm working on building a report and am trying to get the right count of records using the DCOUNT function. I'm in a pickle trying to adjust the CRITERIA part of it, so that it would pull the necessary records. Basically what I'm doing is taking a COUNT of records with the following criteria...

strA = DCount("ClienID", "tempClientInfoA", "Dept = '" & strDept & "' and Status = '1'")

This is currently what I have. I'm taking a count of employees depending on department and STATUS (part time or fullTime). Status 1 is fulltime, but now I need to take into account Part Time which is Status 2. So I'm playing around with the function, but it doesn't seem count the right number of records. this is what I tried with

strA = DCount ("ClientID", "tempClientInfoA", "Dept = '" & strDept & "' and status = '1' or status = '2''") 

this gives me some whacky numbers. How would i go about including the criteria so that it would pull both 1's and 2's?

Thanks!


Solution

  • Issue is to do with the order the AND and OR are evaluated. This was accepted by the OP as working:

    strA = DCount ("ClientID", "tempClientInfoA", "Dept = '" & strDept & "' and (status = '1' or status = '2')")