Avatar of ArisaAnsar
ArisaAnsar
Flag for United States of America asked on

Microsoft Access - Count Function

I have an Access Database and is trying to summaries data.  I have a column that lists the branch locations.  Each locations has multiple account numbers.  How do I calcuate for each branch locations the number of account numbers?
Microsoft Access

Avatar of undefined
Last Comment
AccessYourBiz_Com

8/22/2022 - Mon
SOLUTION
derekkromm

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
peter57r

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ArisaAnsar

ASKER
Thank you both for posting.  I have one record per account and that record has the branch on it.  I am very new to Access so trying to figure out how to implement the instructions you both provided.  I did create a Query, there are other columns but when I try to include the fomula in the Branch Column, I'm getting the following message.

"The expression you entered contains invalid syntax or you need to enclose your text data in quotes."

In the Branch Column, in the criteria section, I have the following:
Branch, Count [Account] as "NumAccts"

Where am I going wrong?
derekkromm

count(account) as "NumAccts"

use (), not [], count is a function
ArisaAnsar

ASKER
I changed as you suggested and is getting the following message.  

"The expression you entered contains invalid syntax. You may have entered an Operand without an operator."

Any other suggestions?  Am I correct in adding this to the Criteria section of the Branch  Column?
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
AccessYourBiz_Com

SELECT BranchAccounts.Branch, Count(BranchAccounts.Account) AS CountOfAccount
FROM BranchAccounts
GROUP BY BranchAccounts.Branch;

BranchAccounts is a Table
Branch is a field for the Branch Location
Account is a feild for the account number.
See attached database for the table and the query.
BranchAccounts.zip
ArisaAnsar

ASKER
Thank you very much for taking the extra step to create a sample database.   I have numerous columns in my query and for some reason, its still not working the same.

When I run the query, it counts each account number once and counts that account only once.  I attached two screenshots below so you can see.

Thanks so very much for your help.
Access-Count-Query-Issue.bmp
Access-Count-Query-Issue1.bmp
AccessYourBiz_Com

if you can post a subset of your database I can help. Without having the actuall fields and some data it may be difficult to provide the proper SQL statement.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ArisaAnsar

ASKER
Thanks again.  Sample file attached.
Branch-Tables-Test.zip
peter57r

If you include other fields as  'group by' fields then you cannot get a count just for the branch.  You will get a count for each unique set of all the group fields.

In a totals query you can only include fields which are necessary to get the summaries you want.

ArisaAnsar

ASKER
Thanks!  Is there a way to remove the "group by" from the other columns without impacting the two columns?
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
AccessYourBiz_Com

Yes, you can change GROUP BY to "FIRST" or LAST or MIN or MAX. Then it will give you the FIRST occurance of the data for that field or the LAST occurannce, etc.
ASKER CERTIFIED SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ArisaAnsar

ASKER
Thanks for all of you for responding.   I appreciate your help very much.
The function is finally working correctly.
AccessYourBiz_Com

welcome :-)
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.