Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How Do I read from a Recordet not starting at the first record

Status
Not open for further replies.

JamesBBB

Technical User
Nov 2, 2005
74
0
0
GB
Hi All

Another poser, I would like to read a recorset, however I dont want to start at record one, Basically I want to read the first 20 records, display the first 20 records, and if the user wants to continue , he can click a continue button and it will display the next 20 records and so on, also ther will be a previous buttong to allow him to go back wards by 20 records.

Is this possible

Currently I have

While not rst.EOF
For X = 1 to 20
aStr = rst![Album]
me("Text" & & 20).value = aStr

rst.movenext
If X = 20 then
Exit SUb
End if

Next
Wend

rst.close

So as you can see, extremely basic and does the first 20, but I havent a clue how to continue.

Any help would be very gratefully received

Many thanks

James
 
This is how I would do it using sql and a bound continous form. I did this using Northwind and a form based on the Products table. It cycles 20 records at a time, and then starts over. The form is bound to a query showing the firts TOP 20 records.

Code:
Public intCycle20

Private Sub cmdCycle20_Click()
  Dim strSql As String
  intCycle20 = intCycle20 + 20
  If Me.Recordset.RecordCount < 20 Then
    intCycle20 = 0
    strSql = "SELECT TOP 20 * FROM Products"
  Else
    strSql = "SELECT TOP 20 * FROM Products WHERE ProductID NOT IN (SELECT TOP " & intCycle20 & " ProductID from Products)"
  End If
  Me.RecordSource = strSql
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top