PC Review


Reply
Thread Tools Rate Thread

Counting the total number of records in a query

 
 
=?Utf-8?B?VVNfU29sZGllcjMxNQ==?=
Guest
Posts: n/a
 
      17th Nov 2007
How could i have access count the total number of records in a specific query?

 
Reply With Quote
 
 
 
 
Rick Brandt
Guest
Posts: n/a
 
      17th Nov 2007
US_Soldier315 wrote:
> How could i have access count the total number of records in a
> specific query?


DCount("*", "QueryName")

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com


 
Reply With Quote
 
 
 
 
fredg
Guest
Posts: n/a
 
      17th Nov 2007
On Sat, 17 Nov 2007 07:46:01 -0800, US_Soldier315 wrote:

> How could i have access count the total number of records in a specific query?


=DCount("*","QueryName")
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
 
Reply With Quote
 
=?Utf-8?B?VVNfU29sZGllcjMxNQ==?=
Guest
Posts: n/a
 
      17th Nov 2007
It has been a long time since I have had to do this stuff. where do i need
to put that function?

"fredg" wrote:

> On Sat, 17 Nov 2007 07:46:01 -0800, US_Soldier315 wrote:
>
> > How could i have access count the total number of records in a specific query?

>
> =DCount("*","QueryName")
> --
> Fred
> Please respond only to this newsgroup.
> I do not reply to personal e-mail
>

 
Reply With Quote
 
=?Utf-8?B?VVNfU29sZGllcjMxNQ==?=
Guest
Posts: n/a
 
      17th Nov 2007
Let me tell you what i am trying to do and you might be able to help me better.

I have 3 queries: Enlisted, Warrant, & Officer.
I am trying to create another query that will tell me how many records are
in each query. Is that possible? It has been a while since I have done this
stuff.

"fredg" wrote:

> On Sat, 17 Nov 2007 07:46:01 -0800, US_Soldier315 wrote:
>
> > How could i have access count the total number of records in a specific query?

>
> =DCount("*","QueryName")
> --
> Fred
> Please respond only to this newsgroup.
> I do not reply to personal e-mail
>

 
Reply With Quote
 
Michael Gramelspacher
Guest
Posts: n/a
 
      17th Nov 2007
A union query might work

SELECT 'Enlisted' AS Category, Count(*) AS [Category Count]
FROM (Select * FROM Soldiers Where Soldiers.service_category = 'Enlisted')
UNION ALL
SELECT 'Officer', Count(*) AS [Category Count]
FROM (Select * FROM Soldiers Where Soldiers.service_category = 'Officer')
UNION ALL
SELECT 'Warrant', Count(*) AS [Category Count]
FROM (Select * FROM Soldiers Where Soldiers.service_category = 'Warrant');

but maybe simply:

SELECT Soldiers.service_category,
COUNT(* ) AS [Category Count]
FROM Soldiers
GROUP BY Soldiers.service_category;

73C

On Sat, 17 Nov 2007 09:25:00 -0800, US_Soldier315
<(E-Mail Removed)> wrote:

>Let me tell you what i am trying to do and you might be able to help me better.
>
>I have 3 queries: Enlisted, Warrant, & Officer.
>I am trying to create another query that will tell me how many records are
>in each query. Is that possible? It has been a while since I have done this
>stuff.

 
Reply With Quote
 
fredg
Guest
Posts: n/a
 
      17th Nov 2007
On Sat, 17 Nov 2007 09:25:00 -0800, US_Soldier315 wrote:

> Let me tell you what i am trying to do and you might be able to help me better.
>
> I have 3 queries: Enlisted, Warrant, & Officer.
> I am trying to create another query that will tell me how many records are
> in each query. Is that possible? It has been a while since I have done this
> stuff.
>
> "fredg" wrote:
>
>> On Sat, 17 Nov 2007 07:46:01 -0800, US_Soldier315 wrote:
>>
>>> How could i have access count the total number of records in a specific query?

>>
>> =DCount("*","QueryName")
>> --
>> Fred
>> Please respond only to this newsgroup.
>> I do not reply to personal e-mail
>>


I'll use 2 queries to show as an example, but you can use 3.
Why are you doing this in a query. I would guess that you would want
this count to be shown either on a form or in a report.
In which case, use an unbound control.
Set it's control source to:
= "Count Enlisted " & DCount("*","Enlisted")

Do similar for each other query count needed.
Or, you could combine them into one control:

= "The Enlisted count is " & DCount("*","Enlisted") & " and the
Officer count is " & DCount("*","Officer ")

You could do it in a query:
Type directly into the SQL View of a NEW query, the following:

SELECT DCount("*","Enlisted") AS CountEnlisted,
DCount("*","Officer") AS CountOfficers;

You will get 1 record with 2 columns showing just the total count from
each query.

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Counting records in query and populating new field with total results.. tina Microsoft Access Queries 0 26th Oct 2008 06:37 PM
using total number of records for random number scubadiver Microsoft Access 2 22nd Feb 2008 04:29 PM
Number of Records pulled by Query don't match number of records in table Rebekah Microsoft Access Queries 7 15th Sep 2004 08:08 PM
Report showing current total, previous total and average total? Richard Black Microsoft Access Reports 3 20th Jul 2004 01:22 PM
Counting the number of records in a report by group, then overall total Charlie Microsoft Access Reports 3 22nd Apr 2004 12:56 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:59 PM.