Kris Kris - 11 months ago 63
SQL Question

CountIf formula within MS Access report

Something terrible as happened with my poor attempt at adding a

forumula to my access report.

I am trying to add a formula within my report header to count the number of entries in my
column that contain a certain word. The problem is I am an absolute amateur when it comes to SQL code.


Is the code I was hoping would work but I don't seem to be getting anywhere.


There is no Countif function in Access. However, you can use Sum and IIf (ie, Immediate If) to accomplish the same thing. Try:

=Sum(IIf([Service] Like "*Housing*", 1, 0))

The above assumes you want the Service column to contain the word "Housing". This assumes you were being precise in the wording of your question. If you really meant that you want to count the number of records where the Service column equals "Housing" exactly, you would use this instead:

=Sum(IIf([Service] = "Housing", 1, 0))