Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

Business Applications Business Applications
Search Search
Search for:
Tech Support Guy > > >

Solved: Is there a 'CountIf' function for Access?


(!)

DKTaber's Avatar
DKTaber   (Don) DKTaber is offline
Computer Specs
Member with 2,550 posts.
THREAD STARTER
 
Join Date: Oct 2001
Location: Wilmington, DE
Experience: Advanced
28-Nov-2007, 04:06 PM #1
Solved: Is there a 'CountIf' function for Access?
Have an Access 2000 report in which I would like to get a count of each different value in a single-character text field. The file can have the values A, B, E, and M. So in the report footer, I want four fields that count the A's, the B's, the E's and the M's separately. In other words, the same thing CountIf does in Excel. I can't find such a function in Access. Is there such a function?
jimr381's Avatar
Computer Specs
Member with 4,175 posts.
 
Join Date: Jul 2007
Location: Vienna, VA
Experience: Computer Illiterate
28-Nov-2007, 04:11 PM #2
No and Yes. No there is not a countif persay, but you can nest an Iif within a count function like this.
=count(Iif([field]=value))

For Yours it would be:

=count(Iif([fieldname]="A"))


=count(Iif([fieldname]="B"))

Each of these will be placed in separate text boxes.
DKTaber's Avatar
DKTaber   (Don) DKTaber is offline
Computer Specs
Member with 2,550 posts.
THREAD STARTER
 
Join Date: Oct 2001
Location: Wilmington, DE
Experience: Advanced
28-Nov-2007, 04:17 PM #3
Quote:
Originally Posted by jimr381
No and Yes. No there is not a countif persay, but you can nest an Iif within a count function like this.
=count(Iif([field]=value))

For Yours it would be:

=count(Iif([fieldname]="A"))


=count(Iif([fieldname]="B"))

Each of these will be placed in separate text boxes.
Thanks for the quick response. I'll try it a let you know if it worked.
jimr381's Avatar
Computer Specs
Member with 4,175 posts.
 
Join Date: Jul 2007
Location: Vienna, VA
Experience: Computer Illiterate
28-Nov-2007, 04:20 PM #4
Not a problem make sure you replace fieldname with the actual field name you are counting data within.
DKTaber's Avatar
DKTaber   (Don) DKTaber is offline
Computer Specs
Member with 2,550 posts.
THREAD STARTER
 
Join Date: Oct 2001
Location: Wilmington, DE
Experience: Advanced
28-Nov-2007, 04:25 PM #5
Quote:
Originally Posted by jimr381
Not a problem make sure you replace fieldname with the actual field name you are counting data within.
I did that, and it doesn't work; get an error message "The expression you entered has a function containing the wrong number of arguments". ????
jimr381's Avatar
Computer Specs
Member with 4,175 posts.
 
Join Date: Jul 2007
Location: Vienna, VA
Experience: Computer Illiterate
28-Nov-2007, 04:31 PM #6
Whoops let me try that again.

Quote:
Originally Posted by jimr381
No and Yes. No there is not a countif persay, but you can nest an Iif within a count function like this.
=count(Iif([field]=value))

For Yours it would be:

=count(Iif([fieldname]="A",1))


=count(Iif([fieldname]="B",1))

Each of these will be placed in separate text boxes.
Just add the ,1 in there as well.
DKTaber's Avatar
DKTaber   (Don) DKTaber is offline
Computer Specs
Member with 2,550 posts.
THREAD STARTER
 
Join Date: Oct 2001
Location: Wilmington, DE
Experience: Advanced
29-Nov-2007, 08:43 AM #7
Quote:
Originally Posted by jimr381
Whoops let me try that again.
Just add the ,1 in there as well.
Yep, that was it. I figured that out shortly after my last reply because the Iif statement didn't have a result. Works perfectly. Thanks much.
jimr381's Avatar
Computer Specs
Member with 4,175 posts.
 
Join Date: Jul 2007
Location: Vienna, VA
Experience: Computer Illiterate
29-Nov-2007, 08:48 AM #8
Not a problem can you please mark the post as solved via the "Thread Tools" drop-down list at the top of the post?
DKTaber's Avatar
DKTaber   (Don) DKTaber is offline
Computer Specs
Member with 2,550 posts.
THREAD STARTER
 
Join Date: Oct 2001
Location: Wilmington, DE
Experience: Advanced
29-Nov-2007, 10:00 AM #9
Quote:
Originally Posted by jimr381
Not a problem can you please mark the post as solved via the "Thread Tools" drop-down list at the top of the post?
Just did.
As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
WELCOME TO TECH SUPPORT GUY!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.


(clock)
THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑