ADO gives 3 properties to help you.
PageSize - sets / returns the number of records in a single page.
PageCount - returns the number of pages in a record set
AbsolutePage - Sets / returns the current page of records.
Here is a sample code.
option explicit
private iCurrentPage as integer
I am using a button to get the record set. On clicking the button, it will list records page by page.
In the click event, put the code.
If iCurrentPage="" then
iCurrentPage = 1
else
iCurrentPage = iCurrentPage +1
end if
' set ADO connection object. Let cnn be the ado connection object.
dim rs as new adodb.recordset
rs.CursorType=adopenstatic
rs.PageSize=10
rs.open <query to open record set>, cnn
rs.absolutepage=iCurrentPage
dim iRowCount as Integer
iRowCount=0
While not(rs.EOF) and iRowCount<rs.PageSize
' code to display record fields.
iRowCount=iRowCount+1
rs.MoveNext
wend
rs.close
set rs=nothing
' close connection
--------------------------------------------------------------
This code should be used only as a guide line. Please do not cut and paste. I have not had a chance to test it. I am writing it from my memory.
Best wishes
Madhu
|