If is used in VB code:
If A=B then
'some code
Else
'some different code
end if
IIF is the immediate if used in functions:
IIF(A=B,True expression, False expression)
In order to achieve your specific results, you'll need to have a sum in either a report or group footer. The text box should have the following control source (or something like it):
=Sum(iif([xfield]=value,1,0)