Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Counting detail records returned in a query

5 views
Skip to first unread message

David Kistner

unread,
Sep 25, 2004, 8:57:48 AM9/25/04
to
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

Melissa

unread,
Sep 25, 2004, 9:45:09 AM9/25/04
to
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
reso...@pcdatasheet.com
www.pcdatasheet.com

"David Kistner" <spamca...@verizon.net> wrote in message
news:gXd5d.942$Mf.413@trnddc05...

David Kistner

unread,
Sep 25, 2004, 1:56:01 PM9/25/04
to
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

PC Datasheet

unread,
Sep 25, 2004, 5:12:14 PM9/25/04
to
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
reso...@pcdatasheet.com
www.pcdatasheet.com


"David Kistner" <spamca...@verizon.net> wrote in message

news:Rii5d.1910$2t5.331@trnddc07...

David Kistner

unread,
Sep 25, 2004, 6:25:13 PM9/25/04
to
Thank you. That worked and I have exactly what I was looking for.

- David Kistner

0 new messages