Home |
Search |
Today's Posts |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Colon at the end of excel file name(ex: problem.xls:1, problem.xls | New Users to Excel | |||
=IF problem | Excel Discussion (Misc queries) | |||
If then problem | Excel Worksheet Functions | |||
Started out as an Access problem. Now an Excel problem | Excel Discussion (Misc queries) | |||
problem with a conditional max problem | Excel Discussion (Misc queries) |