Using the =Count Expression

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to use the count function to count the number of instances a
yes/no checkbox appears on my report. I have spent a lot of time trying to
find the answer in the help index area of access to no avail.

If someone has a minute, could you pass along the ideas on the expression I
would use to count the total number of times a chcekbox = Yes or true in my
report? I certainly thank you in advance for your help.

Janell
 
Janell

Horizontal or vertical?

Reports rely on data taken from tables (possibly via queries).

Does your table have a single yes/no field, so that your report is counting
# of rows? Or does your table contain multiple (?repeating) yes/no fields,
and your report is "counting" fields/columns?

The former is the preferred data structure (i.e., more normalized), while
the latter is what you would find if this data started life as a
spreadsheet.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
Hello Jeff. Thanks for responding.
The yes/no check boxes are by record. Maybe it would be easier to describe
the database to explain what I am doing. I have a db of about 500 records.
I keep track of membership in my organization with this database and one of
the uses is tracking conference registration. One of the fields (columns) in
my DB is a column using the yes no checkbox to indicate if the user wants a
vegetarian meal at the conference. The default for everyone is unchecked
(no). If the user indicates they want a vegetarian meal, I woul dcheck the
cob.

This is of course in a query and thus a report is built off it. In the
report when I count on the vegitarian check box, I am getting a count of the
number of checkboxes on the rport (whether they are checked or unchecked). I
only want a total number of vegetarian meals. I may have 10 records on the
conference registration report, but if 5 of the 10 records have the veg meal
checkd yes, that is the number I want calculated. Does this make sense? Or
am I trying to do something Access is not able to accopmodate. As you can
see I am a fairly new user. Thanks again for your time.
Janell
 
Janell

Since Access uses a "0" for False/No, and a "-1" for True/Yes, you can use
=Sum([YourField]). If you don't care to see the minus sign, you can use
=Abs(Sum([YourField])).

Good luck!

Jeff Boyce
Microsoft Office/Access MVP
 
Jeff:
Your suggestion has worked. I used the =abs(sum... option provided. If
you do not mind... what is the difference between the =abs and =sum funtion?
I guess I am wondering why my count function did not produce my intended
result. Is it that the count function just counts instances of a preset
criteria? As you stated the no or false value = 0 and yes = -1 so I guess I
understand why the sum function would work in that manner. But why does the
=Abs function make the - sign go away?
Should I ask also why the sky is blue and the stars sparkle??? :o) I am
just like a sponge lately with this stuff.... just trying to soak it all in
as I learn!

Anyhow, thank you for your assistance. It is appreciated, Janell Craig
Jeff Boyce said:
Janell

Since Access uses a "0" for False/No, and a "-1" for True/Yes, you can use
=Sum([YourField]). If you don't care to see the minus sign, you can use
=Abs(Sum([YourField])).

Good luck!

Jeff Boyce
Microsoft Office/Access MVP

Jcraig713 said:
Hello Jeff. Thanks for responding.
The yes/no check boxes are by record. Maybe it would be easier to
describe
the database to explain what I am doing. I have a db of about 500
records.
I keep track of membership in my organization with this database and one
of
the uses is tracking conference registration. One of the fields (columns)
in
my DB is a column using the yes no checkbox to indicate if the user wants
a
vegetarian meal at the conference. The default for everyone is unchecked
(no). If the user indicates they want a vegetarian meal, I woul dcheck
the
cob.

This is of course in a query and thus a report is built off it. In the
report when I count on the vegitarian check box, I am getting a count of
the
number of checkboxes on the rport (whether they are checked or unchecked).
I
only want a total number of vegetarian meals. I may have 10 records on
the
conference registration report, but if 5 of the 10 records have the veg
meal
checkd yes, that is the number I want calculated. Does this make sense?
Or
am I trying to do something Access is not able to accopmodate. As you can
see I am a fairly new user. Thanks again for your time.
Janell
 
Janell

Abs() is the absolute value function (back to school!). The absolute value
of a number is the positive equivalent. Since Access uses a -1 for each
True/Yes, your Sum() would result in a number like -3 or -7 or -156. The
Abs() function just converts it to a (less confusing) positive number.

Regards

Jeff Boyce
Microsoft Office/Access MVP

Jcraig713 said:
Jeff:
Your suggestion has worked. I used the =abs(sum... option provided. If
you do not mind... what is the difference between the =abs and =sum
funtion?
I guess I am wondering why my count function did not produce my intended
result. Is it that the count function just counts instances of a preset
criteria? As you stated the no or false value = 0 and yes = -1 so I guess
I
understand why the sum function would work in that manner. But why does
the
=Abs function make the - sign go away?
Should I ask also why the sky is blue and the stars sparkle??? :o) I am
just like a sponge lately with this stuff.... just trying to soak it all
in
as I learn!

Anyhow, thank you for your assistance. It is appreciated, Janell Craig
Jeff Boyce said:
Janell

Since Access uses a "0" for False/No, and a "-1" for True/Yes, you can
use
=Sum([YourField]). If you don't care to see the minus sign, you can use
=Abs(Sum([YourField])).

Good luck!

Jeff Boyce
Microsoft Office/Access MVP

Jcraig713 said:
Hello Jeff. Thanks for responding.
The yes/no check boxes are by record. Maybe it would be easier to
describe
the database to explain what I am doing. I have a db of about 500
records.
I keep track of membership in my organization with this database and
one
of
the uses is tracking conference registration. One of the fields
(columns)
in
my DB is a column using the yes no checkbox to indicate if the user
wants
a
vegetarian meal at the conference. The default for everyone is
unchecked
(no). If the user indicates they want a vegetarian meal, I woul dcheck
the
cob.

This is of course in a query and thus a report is built off it. In the
report when I count on the vegitarian check box, I am getting a count
of
the
number of checkboxes on the rport (whether they are checked or
unchecked).
I
only want a total number of vegetarian meals. I may have 10 records on
the
conference registration report, but if 5 of the 10 records have the veg
meal
checkd yes, that is the number I want calculated. Does this make
sense?
Or
am I trying to do something Access is not able to accopmodate. As you
can
see I am a fairly new user. Thanks again for your time.
Janell

:

Janell

Horizontal or vertical?

Reports rely on data taken from tables (possibly via queries).

Does your table have a single yes/no field, so that your report is
counting
# of rows? Or does your table contain multiple (?repeating) yes/no
fields,
and your report is "counting" fields/columns?

The former is the preferred data structure (i.e., more normalized),
while
the latter is what you would find if this data started life as a
spreadsheet.

Regards

Jeff Boyce
Microsoft Office/Access MVP

I am trying to use the count function to count the number of
instances a
yes/no checkbox appears on my report. I have spent a lot of time
trying
to
find the answer in the help index area of access to no avail.

If someone has a minute, could you pass along the ideas on the
expression
I
would use to count the total number of times a chcekbox = Yes or
true
in
my
report? I certainly thank you in advance for your help.

Janell
 

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

Back
Top