counting yes/no fields

J

Joachim

I have an access table where i need to make a query to count the meals they
eat in school in a week for a group of people.
In the query i want to show the name of the person and how many meals he
eats a week at school
In my table i've made yes/no fields a day for those people ,
so actually i need to make a query who counts to yes' of the 5 yes/no fields
 
V

vanderghast

abs(field1+field2+field3+field4+field5)


it is based on the fact that a no is 0 and a yes is -1. Note that yes can
be anything that is not 0, but since I suspect you don't have an integer
field, but a boolean field, we can assume yes is -1. You can play safe,
though, using:

abs( field1<>0 + field2 <> 0 + field3 <> 0 + field4 <> 0 + field5 <>0 )



Vanderghast, Access MVP
 
J

Joachim

where do i have to fill in this formula ?
And do i have to use a totals query?

--
Looking forward to your reply

thx already


vanderghast said:
abs(field1+field2+field3+field4+field5)


it is based on the fact that a no is 0 and a yes is -1. Note that yes can
be anything that is not 0, but since I suspect you don't have an integer
field, but a boolean field, we can assume yes is -1. You can play safe,
though, using:

abs( field1<>0 + field2 <> 0 + field3 <> 0 + field4 <> 0 + field5 <>0 )



Vanderghast, Access MVP
 
J

John Spencer

That is a calculated field and it should be entered in a field "cell" if you
are using the query design view.

Field: MealCount: abs(field1+field2+field3+field4+field5)

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 

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