Count records based on combo box value

D

davea

Hi

I have a continuous form set up that stores person details name, DoB,
gender etc. Gender is a combo box which stores either a 1 or 0.

I have two fields in the footer of the form which I would like to use
to Count the number of males (1's) and females (0's) in the form.

At the moment it contains =Count([Gender]) which of course returns a
count of all the records.

Can someone tell me what syntax I should be using for each field to
separate the count of males/females?CountIf or something similar?
 
G

Guest

Hi Dave,

There are a couple of ways to get the counts of M/F.

Since males = 1, to count the males, you can use


= Sum([Gender])

or

= Sum(IIF([Gender]=1,1,0))

or

= Sum(IIF([Gender]<>0,1,0))


To count the females, you can use

=Sum(Not [Gender])*-1

or

= Sum(IIF([Gender]=0,1,0))

or

= Sum(IIF([Gender]<>1,1,0))

If you wanted to check if there was an entry that was not 0 and not 1, you
could use

=Sum(IIf([gender]<>0 And [Gender]<>1,1,0))


(some one is both male and female or neither male or female??) :-D



HTH
 

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

Top