View Full Version : rs.recordcount
04-07-2006, 11:54 PM
How I do to reduce/change the real value of rs.recordcount in 20% ?
if rs.recordcount>10 then
if rs.recordcount>20 then
But this not works. Thios not change the real value of rs.recordcount!
04-09-2006, 01:18 AM
you do realize that if you don't use a static cursor when you open the recordset that the value of rs.recordcount is always -1 don't you? Make sure you are using a static cursor. That is done like this
rs.open "SELECT * FROM widgets",conn, 3
rs.open "SELECT * FROM widgets",conn, adOpenStatic
04-10-2006, 02:56 PM
Another option is to loop through to count the records
rs_total = rs.RecordCount
If (rs_total = -1) Then
' count the total records by iterating through the recordset
While (Not rs.EOF)
rs_total = rs_total + 1
' reset the cursor to the beginning
If (rs.CursorType > 0) Then
04-11-2006, 01:33 PM
Why would you loop through to get the count? That is a very inefficient way of doing it. And if you have result in millions it could cause the server to timeout before the result was displayed.
You could also use rs.GetRows then just get the upper limit of the array. By using a static cursor or using GetRows, either way is much more efficient than looping through the recordset.
aRows = rs.GetRows
totalput = UBound(aRows,2)
04-23-2006, 08:34 PM
Hi, Miranda and Degsy,
Sorry, but I am busy of work! I had not time to try your scripts!
The suggestion of Miranda makes sense.
I find a rude and 'home' solution:
recordsToShow = 5
For i = 1 To calculo
rcount = i
If currentPage > 1 Then
For x = 1 To (currentPage - 1)
rcount = 10 + rcount
In this way, instead to show 10 results it show only 6!
Could I use the following?
select top 1000 from mytable
Thank you again
04-25-2006, 04:48 PM
Do you want a page to specifically output a certain amount of records or do you want paging?
The techniques would be different.
With paging you would grab all of the records and use a counter to tell the script how many to output.
04-25-2006, 08:56 PM
I want a page to specifically output a certain amount of records!
Now I found other and best way to do this:
select TOP 20 percent from tableA
But it is a 'straitjacket'.
Could I do this: SELECT TOP 20 PERCENT (TOP 1000) FROM TABLEA ????
or similar thing?
Thank you for your interest in help me!
04-26-2006, 01:10 PM
In Access you can use Percent.
SELECT TOP 20 Percent FROM table
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.