Search code examples
ms-accessdcount

Dcount in MS Access not filtering correctly


I am doing a dcount in a form through a textbox. I just need it to add the reasons in the table filtered through the reason type and clientid from the open form. The form is open and the dcount counts all records of type letter but does not filter by client.

Any suggestions?

 =DCount("reason","dbo_TimerTable","reason = letter" And "ClientID = Forms![Clients]![ClientID]")

Solution

  • The parameter must be outside of the string, and the criterium must be one expression.

    =DCount("reason","dbo_TimerTable","reason = letter And ClientID = " & Forms![Clients]![ClientID])
    

    Although I would think that with reason being a text field, you'd need:

    =DCount("reason","dbo_TimerTable","reason = 'letter' And ClientID = " & Forms![Clients]![ClientID])
    

    but you said the filtering by reason already worked...