Counting the number of records in a query

J

Jim Buyens

-----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)
|/---------------------------------------------------
*----------------------------------------------------
 
D

Dan

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
|/--------------------------------------------------
*---------------------------------------------------
 
D

Dan

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
 
J

Jim Buyens

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.
 
D

Dan

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
 
J

Jim Buyens

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)
|/---------------------------------------------------
*----------------------------------------------------
 
Top