473,322 Members | 1,352 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

How to count individual items in a value list

Access 2010. I have a drop down list with "Male" or "Female" as the choice. I wish to count the number of Males and the number of Females to show on a report. The Field name is [Gender] which is stored in a table.

Is there a code to use in an unbounded text box that will show the totals on a report? I have tried =Count(If[Gender])="Female")) and it returns 'Error' as the value.

Thank you,
Bob
Sep 7 '10 #1

✓ answered by NeoPa

Actually, I may have missed the more obvious problem with your attempt. If the control is called [Gender] (rather than just the field) then your code would need to be something like :
Expand|Select|Wrap|Line Numbers
  1. =Count(IIf([Gender]='Female',[Gender],Null)
or even :
Expand|Select|Wrap|Line Numbers
  1. =Sum(IIf([Gender]='Female',1,0)

5 3380
colintis
255 100+
As you said, the gender data is store in a table, so you'll need a query to run instead. Something like this:

Expand|Select|Wrap|Line Numbers
  1. select count(*) as total, 
  2.   sum(iif(gender = 'male',1,0)) as male, 
  3.   sum(iif(gender = 'female',1,0)) as female 
  4. from mytable
  5.  
Sep 7 '10 #2
NeoPa
32,556 Expert Mod 16PB
In your footer you can use the standard aggregate functions (Count(), Sum(), etc), but they can only refer to controls on your report object, not to the fields of the record source.

The items that are aggregated will depend on the level of the footer involved.

Welcome to Bytes!
Sep 7 '10 #3
NeoPa
32,556 Expert Mod 16PB
Actually, I may have missed the more obvious problem with your attempt. If the control is called [Gender] (rather than just the field) then your code would need to be something like :
Expand|Select|Wrap|Line Numbers
  1. =Count(IIf([Gender]='Female',[Gender],Null)
or even :
Expand|Select|Wrap|Line Numbers
  1. =Sum(IIf([Gender]='Female',1,0)
Sep 7 '10 #4
Yes,that works. Thank you to Neopa and Colintis for your help. I appreciate it.
Sep 7 '10 #5
NeoPa
32,556 Expert Mod 16PB
It's a pleasure Bob. I'm glad it helped :)
Sep 7 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: M. Clift | last post by:
Hi All, This would seem to be easy, but I have had no luck in working out how to do this. In wx.python a list of text is displayed as a bitmap and given it's position. shape.pos = (145,...
0
by: Priya | last post by:
I want to disable individual items in a listbox,listview in C#.NEt
2
by: kranthi | last post by:
I want to disable individual items in a listbox or listview
0
by: Larry | last post by:
Although there are font attribute properties for the items in a ListView component, the complier tells me that they are read-only. Is there any way to get access and change the font poperties of...
2
by: Brian Mitchell | last post by:
Is it possible to gray out individual items in the CheckedListBox? I have an option at the top of the list that simply says 'All', and when the user clicks that item I want the rest of the items in...
0
by: satish | last post by:
Hi , I am automating internet. I am using mshtml and shdocvw.ddl for automations Can anyone tell me how to automate selection of items from list the e.g of html source is as given <select...
2
by: josecruz | last post by:
I have created a combo box for my form. This box displays the individual items properly and runs the report on that particular selection. My question is. How do I code so that a selection of display...
2
by: sideejay | last post by:
I added some items to my value list in a table but I noticed the value list in the form did not get updated. Why is that? I would have figured they would have a relationship. It is a music...
2
by: redeye | last post by:
Hi All, I need to do a count of individual items in one column I call status. The status column contains only three values (‘Not Available’, Partially Available’, ‘Fully Available’). My sql...
5
by: r3bol | last post by:
Hi, sorry to post this, but I've had a really hard time finding how to do it. Q. How can I break up a value in a list to a list of individual items (preferably without importing any modules)?...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.