Counting records that are not 0

T

Tony Williams

I have a query that I want to count the number of records where the value of
a field "txtFactClients" is not 0. I have set up an expression "CountFC:
txtFactClients" with Count selected in the Total line and [txtFactClients]>0
in the criteria line but when I run the query it counts every record whether
or not it is 0. I've looked at previous post but they all seem to involve
SQL, is there a way of doing this in the design mode of a query?
TIA
Tony
 
P

PC Datasheet

Remove your expression and just pull down txtFactClients into the query
grid. Set the criteria as:
<>0
Count needs to be selected in the Total line.
Access will rename the field "CountOftxtFactClients" in the query results.
 
J

John Spencer (MVP)

One method would be to use something like the following.

Field: IIF(txtFactClients = 0,Null,txtFactClients)
Total: Count

When Counting Access does not care what the value is. It counts whether or not
any value exists. The only thing it does not count is null values.
 
T

Tony Williams

Thanks John
Tony
John Spencer (MVP) said:
One method would be to use something like the following.

Field: IIF(txtFactClients = 0,Null,txtFactClients)
Total: Count

When Counting Access does not care what the value is. It counts whether or not
any value exists. The only thing it does not count is null values.

Tony said:
I have a query that I want to count the number of records where the value of
a field "txtFactClients" is not 0. I have set up an expression "CountFC:
txtFactClients" with Count selected in the Total line and [txtFactClients]>0
in the criteria line but when I run the query it counts every record whether
or not it is 0. I've looked at previous post but they all seem to involve
SQL, is there a way of doing this in the design mode of a query?
TIA
Tony
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Need Query to return record even if Count=0 2
show 0 in crosstabquery 3
Count in a Query 4
Counting in Queries 4
Counting records 1
Counting records 2
Help with query counting unique records??? 12
Show zero count as 0 2

Top