PC Review


Reply
Thread Tools Rate Thread

Counting the number of records in a query

 
 
=?Utf-8?B?RGFu?=
Guest
Posts: n/a
 
      31st May 2004
How do I get a count of the number of records when a query is performed?
 
Reply With Quote
 
 
 
 
Jon Spivey
Guest
Posts: n/a
 
      31st May 2004
Hi,
something like
SELECT COUNT(*) FROM Table

--
Cheers,
Jon
Microsoft MVP - FP

Dan wrote:
> How do I get a count of the number of records when a query is
> performed?



 
Reply With Quote
 
Jim Buyens
Guest
Posts: n/a
 
      31st May 2004
>-----Original Message-----
>How do I get a count of the number of records when a
>query is performed?


If you're using an ADO recordset, the RecordCount
property may contain the information you're looking for.

Set rsMine = New ADODB.Recordset
sql = "select * from mytable "
rsMine.Open sql, strCnxn
NrOfRecs = rsMine.RecordCount

However, for some cursor types and cursor locations, this
property may always be zero. If you encounter this, try a
different cursor type or cursor location, such as

rsMine.CursorLocation = adUseClient
rsMine.Open sql, strCnxnm, adOpenStatic

Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*----------------------------------------------------
|\---------------------------------------------------
|| Microsoft Office FrontPage 2003 Inside Out
||---------------------------------------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/---------------------------------------------------
*----------------------------------------------------

 
Reply With Quote
 
=?Utf-8?B?RGFu?=
Guest
Posts: n/a
 
      31st May 2004
Im calling a query in access to display users registered for a certian course. I want it to list the users registered and show a count of how many users have registered for that course

----- Jim Buyens wrote: ----

>-----Original Message----
>How do I get a count of the number of records when
>query is performed


If you're using an ADO recordset, the RecordCount
property may contain the information you're looking for

Set rsMine = New ADODB.Recordse
sql = "select * from mytable
rsMine.Open sql, strCnx
NrOfRecs = rsMine.RecordCoun

However, for some cursor types and cursor locations, this
property may always be zero. If you encounter this, try a
different cursor type or cursor location, such a

rsMine.CursorLocation = adUseClien
rsMine.Open sql, strCnxnm, adOpenStati

Jim Buyen
Microsoft FrontPage MV
http://www.interlacken.co
Author of
*---------------------------------------------------
|\--------------------------------------------------
|| Microsoft Office FrontPage 2003 Inside Ou
||--------------------------------------------------
|| Web Database Development Step by Step .NET Editio
|| Microsoft FrontPage Version 2002 Inside Ou
|| Faster Smarter Beginning Programmin
|| (All from Microsoft Press
|/--------------------------------------------------
*---------------------------------------------------


 
Reply With Quote
 
=?Utf-8?B?RGFu?=
Guest
Posts: n/a
 
      31st May 2004
Can I use the same idea with the acception of counting from a query not a tabl

SELECT COUNT (*) FROM usercourses (view

----- Jon Spivey wrote: ----

Hi
something lik
SELECT COUNT(*) FROM Tabl

-
Cheers
Jo
Microsoft MVP - F

Dan wrote
> How do I get a count of the number of records when a query i
> performed




 
Reply With Quote
 
Jim Buyens
Guest
Posts: n/a
 
      31st May 2004
Are you doing this with:

o The Frontpage Database Results Wizard?
o Custom ASP code?
o Custom ASP.NET code?
o Something else?

Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*----------------------------------------------------
|\---------------------------------------------------
|| Microsoft Office FrontPage 2003 Inside Out
||---------------------------------------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/---------------------------------------------------
*----------------------------------------------------


>-----Original Message-----
>Im calling a query in access to display users registered

for a certian course. I want it to list the users
registered and show a count of how many users have
registered for that course.
>
> ----- Jim Buyens wrote: -----
>
> >-----Original Message-----
> >How do I get a count of the number of records when

a
> >query is performed?

>
> If you're using an ADO recordset, the RecordCount
> property may contain the information you're looking

for.
>
> Set rsMine = New ADODB.Recordset
> sql = "select * from mytable "
> rsMine.Open sql, strCnxn
> NrOfRecs = rsMine.RecordCount
>
> However, for some cursor types and cursor

locations, this
> property may always be zero. If you encounter this,

try a
> different cursor type or cursor location, such as
>
> rsMine.CursorLocation = adUseClient
> rsMine.Open sql, strCnxnm, adOpenStatic
>
> Jim Buyens
> Microsoft FrontPage MVP
> http://www.interlacken.com
> Author of:
> *---------------------------------------------------

-
> |\--------------------------------------------------

-
> || Microsoft Office FrontPage 2003 Inside Out
> ||--------------------------------------------------

-
> || Web Database Development Step by Step .NET

Edition
> || Microsoft FrontPage Version 2002 Inside Out
> || Faster Smarter Beginning Programming
> || (All from Microsoft Press)
> |/--------------------------------------------------

-
> *---------------------------------------------------

-
>
>
>.
>

 
Reply With Quote
 
=?Utf-8?B?RGFu?=
Guest
Posts: n/a
 
      31st May 2004
DRW and Access queries in combinatio

----- Jim Buyens wrote: ----

Are you doing this with

o The Frontpage Database Results Wizard
o Custom ASP code
o Custom ASP.NET code
o Something else

Jim Buyen
Microsoft FrontPage MV
http://www.interlacken.co
Author of
*---------------------------------------------------
|\--------------------------------------------------
|| Microsoft Office FrontPage 2003 Inside Ou
||--------------------------------------------------
|| Web Database Development Step by Step .NET Editio
|| Microsoft FrontPage Version 2002 Inside Ou
|| Faster Smarter Beginning Programmin
|| (All from Microsoft Press
|/--------------------------------------------------
*---------------------------------------------------


>-----Original Message----
>Im calling a query in access to display users registered

for a certian course. I want it to list the users
registered and show a count of how many users have
registered for that course
>> ----- Jim Buyens wrote: ----
>>>-----Original Message----

>>How do I get a count of the number of records when


>>query is performed
>> If you're using an ADO recordset, the RecordCount

> property may contain the information you're looking

for
>> Set rsMine = New ADODB.Recordse

> sql = "select * from mytable
> rsMine.Open sql, strCnx
> NrOfRecs = rsMine.RecordCoun
>> However, for some cursor types and cursor

locations, this
> property may always be zero. If you encounter this,

try a
> different cursor type or cursor location, such a
>> rsMine.CursorLocation = adUseClien

> rsMine.Open sql, strCnxnm, adOpenStati
>> Jim Buyen

> Microsoft FrontPage MV
> http://www.interlacken.co
> Author of
> *--------------------------------------------------


> |\-------------------------------------------------


> || Microsoft Office FrontPage 2003 Inside Ou
> ||-------------------------------------------------


> || Web Database Development Step by Step .NET

Editio
> || Microsoft FrontPage Version 2002 Inside Ou
> || Faster Smarter Beginning Programmin
> || (All from Microsoft Press
> |/-------------------------------------------------


> *--------------------------------------------------


>>>

>

 
Reply With Quote
 
Jim Buyens
Guest
Posts: n/a
 
      31st May 2004
Well, with the DRW, you have to put two Database Results
Regions on the same page -- one to display the data and
another -- with the same WHERE clause -- to display the
COUNT(*) value.

In a custom ASP page, you can just access the open
recordset's RecordCount property (provided you use a
cursor type and cursor location that supports this
property).

Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*----------------------------------------------------
|\---------------------------------------------------
|| Microsoft Office FrontPage 2003 Inside Out
||---------------------------------------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/---------------------------------------------------
*----------------------------------------------------


>-----Original Message-----
>DRW and Access queries in combination
>
> ----- Jim Buyens wrote: -----
>
> Are you doing this with:
>
> o The Frontpage Database Results Wizard?
> o Custom ASP code?
> o Custom ASP.NET code?
> o Something else?
>
> Jim Buyens
> Microsoft FrontPage MVP
> http://www.interlacken.com
> Author of:
> *---------------------------------------------------

-
> |\--------------------------------------------------

-
> || Microsoft Office FrontPage 2003 Inside Out
> ||--------------------------------------------------

-
> || Web Database Development Step by Step .NET

Edition
> || Microsoft FrontPage Version 2002 Inside Out
> || Faster Smarter Beginning Programming
> || (All from Microsoft Press)
> |/--------------------------------------------------

-
> *---------------------------------------------------

-
>
>
> >-----Original Message-----
> >Im calling a query in access to display users

registered
> for a certian course. I want it to list the users
> registered and show a count of how many users have
> registered for that course.
> >> ----- Jim Buyens wrote: -----
> >>>-----Original Message-----
> >>How do I get a count of the number of records

when
> a
> >>query is performed?
> >> If you're using an ADO recordset, the

RecordCount
> > property may contain the information you're

looking
> for.
> >> Set rsMine = New ADODB.Recordset

> > sql = "select * from mytable "
> > rsMine.Open sql, strCnxn
> > NrOfRecs = rsMine.RecordCount
> >> However, for some cursor types and cursor

> locations, this
> > property may always be zero. If you encounter

this,
> try a
> > different cursor type or cursor location,

such as
> >> rsMine.CursorLocation = adUseClient

> > rsMine.Open sql, strCnxnm, adOpenStatic
> >> Jim Buyens

> > Microsoft FrontPage MVP
> > http://www.interlacken.com
> > Author of:
> > *---------------------------------------------

------
> -
> > |\--------------------------------------------

------
> -
> > || Microsoft Office FrontPage 2003 Inside

Out
> > ||--------------------------------------------

------
> -
> > || Web Database Development Step by Step .NET

> Edition
> > || Microsoft FrontPage Version 2002 Inside

Out
> > || Faster Smarter Beginning Programming
> > || (All from Microsoft Press)
> > |/--------------------------------------------

------
> -
> > *---------------------------------------------

------
> -
> >>>.

> >

>.
>

 
Reply With Quote
 
=?Utf-8?B?TGVv?=
Guest
Posts: n/a
 
      16th Aug 2004
Hello Jon,

Thank you very much for the solution. It solved my problem.


Regards,

Leo

"Jon Spivey" wrote:

> Hi,
> something like
> SELECT COUNT(*) FROM Table
>
> --
> Cheers,
> Jon
> Microsoft MVP - FP
>
> Dan wrote:
> > How do I get a count of the number of records when a query is
> > performed?

>
>
>

 
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
Code for counting number of records in query merry_fay Microsoft Access 7 4th Dec 2009 02:47 AM
Access Query "Show number 0 if no records are selected by counting" johan Microsoft Access 2 28th Jun 2008 01:13 PM
Counting the total number of records in a query =?Utf-8?B?VVNfU29sZGllcjMxNQ==?= Microsoft Access Queries 6 17th Nov 2007 07:55 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
Counting number of records within a query SHAWN Microsoft Access Queries 4 30th Sep 2003 08:27 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:13 PM.