Counting detail records returned in a query

D

David Kistner

When my Access 2002 query returns records, I also want a total count of
the records returned. An example would be: I run my query and return
detail records for college freshmen, (say their names, major, age and
grade point average). I also want to have a count of records returned,
(an example would be if 1357 freshman records were returned I want to
have this count shown). When I try to "Count" it only counts "1" for
each record returned.....but no total for all of the "1"'s returned.

This seems so simple but I can't figure out how to do this. Thanks in
advance for your help.

- David Kistner
 
M

Melissa

Create a second query based on the first query and only include the primary
key. Click on the Sigma button on the toolbar at the top and then go down
and change Group By under the primary key to count. The second query will
return the number of records in the first query.

You can also get the count with the following expression:
CountOfRecords = DCount("[NameOfPrimaryKey]","NameOfFirstQuery")
 
D

David Kistner

Melissa said:
Create a second query based on the first query and only include the primary
key. Click on the Sigma button on the toolbar at the top and then go down
and change Group By under the primary key to count. The second query will
return the number of records in the first query.

You can also get the count with the following expression:
CountOfRecords = DCount("[NameOfPrimaryKey]","NameOfFirstQuery")

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com



When my Access 2002 query returns records, I also want a total count of
the records returned. An example would be: I run my query and return
detail records for college freshmen, (say their names, major, age and
grade point average). I also want to have a count of records returned,
(an example would be if 1357 freshman records were returned I want to
have this count shown). When I try to "Count" it only counts "1" for
each record returned.....but no total for all of the "1"'s returned.

This seems so simple but I can't figure out how to do this. Thanks in
advance for your help.

- David Kistner
Thanks, I did a second query and was able to get an accurate count. I'd
like to have a form and also a report that displays the detail records
that are a result of the query (with the total count on the same
form/report. When I tried this it errored out....it looks like it
doesn't like both queries together like this. Is there some way I can
get the records and the total count to display (like you'd see on a
spreadsheet where you have multiple rows of records with a total of a
column?). Thank you very much in advance.

- David Kistner
 
P

PC Datasheet

Add a textbox to your form or report and put the following in the control
source property:
= DCount("[NameOfPrimaryKey]","NameOfFirstQuery")

You don't need the second query for this.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com


David Kistner said:
Melissa said:
Create a second query based on the first query and only include the primary
key. Click on the Sigma button on the toolbar at the top and then go down
and change Group By under the primary key to count. The second query will
return the number of records in the first query.

You can also get the count with the following expression:
CountOfRecords = DCount("[NameOfPrimaryKey]","NameOfFirstQuery")

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com



When my Access 2002 query returns records, I also want a total count of
the records returned. An example would be: I run my query and return
detail records for college freshmen, (say their names, major, age and
grade point average). I also want to have a count of records returned,
(an example would be if 1357 freshman records were returned I want to
have this count shown). When I try to "Count" it only counts "1" for
each record returned.....but no total for all of the "1"'s returned.

This seems so simple but I can't figure out how to do this. Thanks in
advance for your help.

- David Kistner
Thanks, I did a second query and was able to get an accurate count. I'd
like to have a form and also a report that displays the detail records
that are a result of the query (with the total count on the same
form/report. When I tried this it errored out....it looks like it
doesn't like both queries together like this. Is there some way I can
get the records and the total count to display (like you'd see on a
spreadsheet where you have multiple rows of records with a total of a
column?). Thank you very much in advance.

- David Kistner
 
D

David Kistner

Thank you. That worked and I have exactly what I was looking for.

- David Kistner

PC said:
Add a textbox to your form or report and put the following in the control
source property:
= DCount("[NameOfPrimaryKey]","NameOfFirstQuery")

You don't need the second query for this.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com


Melissa said:
Create a second query based on the first query and only include the
primary
key. Click on the Sigma button on the toolbar at the top and then go
down
and change Group By under the primary key to count. The second query
will
return the number of records in the first query.

You can also get the count with the following expression:
CountOfRecords = DCount("[NameOfPrimaryKey]","NameOfFirstQuery")

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com





When my Access 2002 query returns records, I also want a total count of
the records returned. An example would be: I run my query and return
detail records for college freshmen, (say their names, major, age and
grade point average). I also want to have a count of records returned,
(an example would be if 1357 freshman records were returned I want to
have this count shown). When I try to "Count" it only counts "1" for
each record returned.....but no total for all of the "1"'s returned.

This seems so simple but I can't figure out how to do this. Thanks in
advance for your help.

- David Kistner
Thanks, I did a second query and was able to get an accurate count. I'd
like to have a form and also a report that displays the detail records
that are a result of the query (with the total count on the same
form/report. When I tried this it errored out....it looks like it
doesn't like both queries together like this. Is there some way I can
get the records and the total count to display (like you'd see on a
spreadsheet where you have multiple rows of records with a total of a
column?). Thank you very much in advance.

- David Kistner
 

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