This statement always returns only one record everytime when its executed
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("Select book_name from book")
Dim i As Integer
For i = 0 To rs.RecordCount - 1
lbBooks.AddItem rs!book_name
rs.MoveNext
Next
what could ebe the cause
I believe that the
RecordCountproperty of aRecordsetis set dynamically to the amount of data that has been read from the cursor. That is, when it’s first opened, it’s set to 1; if you dors.MoveLast, it will set it to the actual number of records in the set. However, you then have the problem of moving back to the start: you must have the recordset opened in a particular mode (which I forgot, from the top of my head) to be able to arbitrarily move the cursor pointer back and forward.The usual way of iterating through a cursor is to use a
whileloop, checking for the cursor’s end of file: