Keith said:
I am in query design view I tried to put this into criteria and ger errors
missing ([ etc... Where do I put this command I tried sql wiew bit I
already
have code there and daaind it to the end causes other errors. I their a
simple way for dumb a's like me to do this simple task....The code is
grate
but where to put it?
You wouldn't put it into criteria. It's a calculated field, so you would
put it in the field grid, as a new "field". You would probably give it a
name, rather than letting Access assign one, so you would enter something
like this:
RevCount: Sum(IIf([YourField]='NON_REV', 0, 1)
I can't see the query you are building, so I don't know what other fields
you might be extracting or totalling. It's a bit easier to give an example
in SQL. If you built a simple query just to compute the above value from a
table named "YourTable", its SQL view would look like this:
SELECT Sum(IIf([YourField]='NON_REV', 0, 1) As RevCount
FROM YourTable;
Note that the SQL posted by Jellifish, though different (using a restricted
COUNT), would also work for this purpose. But if you want, say, the total
number of records, the number of NON_REV records, and the number of other
("Rev"?) records, you would have to do something like this:
SELECT
Count(*) As TotalRecords,
Sum(IIf([YourField]='NON_REV', 0, 1) As RevCount
Sum(IIf([YourField]='NON_REV', 1, 0) As NonRevCount
FROM YourTable;
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)