LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default RecordCount problem

Hi Terence,

Unless you use a cursor that builds the entire recordset in advance
there's no way to get a record count because the records haven't been
retrieved yet. Even with a scrollable cursor, you'll usually have to execute
an rs.MoveLast followed by an rs.MoveFirst in order to fully populate the
recordset so that a count can be retrieved.

This can be a pretty resource intensive operation. If you really need to
know in advance exactly how many records you're going to get back, it's
often better to do a separate SELECT COUNT(*) query using the conditions in
your final SQL statement. The result of this query will be the number of
records returned when you execute the full SELECT statement.

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"Terence" wrote in message
...
Hi,

In my macro, I created an ADO recordset to hold the data.
But why I always get -1 when I use "rst.RecordCount" even
though the recordset is not empty?
Anyone knows?
Thanks a lot.

Terence



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Colon at the end of excel file name(ex: problem.xls:1, problem.xls financeguy New Users to Excel 2 January 15th 10 01:15 AM
=IF problem DaveAsh Excel Discussion (Misc queries) 5 February 4th 09 03:06 PM
If then problem dodgers32 Excel Worksheet Functions 1 February 26th 07 01:51 AM
Started out as an Access problem. Now an Excel problem RobertM Excel Discussion (Misc queries) 2 April 26th 06 07:30 PM
problem with a conditional max problem Brian Cornejo Excel Discussion (Misc queries) 1 February 18th 05 06:25 PM


All times are GMT +1. The time now is 03:43 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"