using dcount for multiple critera

T

Tim

How do I write an expression using dcount if I want two fields for my critera?

For example I want to count all my classes for history and that staff person.

Count for class = history and staff = Mr. Johnson.

My fields are class and staff and my table is courses.

I need to concatenate the fields.

Thanks.
 
F

fredg

How do I write an expression using dcount if I want two fields for my critera?

For example I want to count all my classes for history and that staff person.

Count for class = history and staff = Mr. Johnson.

My fields are class and staff and my table is courses.

I need to concatenate the fields.

Thanks.

You have posted to a Form's newsgroup, so I'll assume this is to be
done on a form.

DCount counts the number of values in your table, not necessarily the
number of Staff and Class in your form's record source.
To use DCount with your specific criteria, using and Unbound control
on your form:

=DCount("*","TableName","[Class] = 'History' and [Staff] = 'Mr.
Johnson'")

The above assume the datatype of Class and Staff is text, not number.

If there is a chance that the Staff name value might contain an
apostrophe, i.e. O'Connor, then use:

=DCount("*","TableName","[Class] = 'History' and [Staff] = """Mr.
O'Connor"""")
 

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