recordset starts halfway

Marcel2586

Registered User.
Local time
Today, 11:47
Joined
Mar 1, 2012
Messages
41
Hello,

I have a problem with my code.
It works, but it starts with row number 15, field number 2
then it go's to row 16, field number 1. then row 16, field 2
Why wont it start at row one, field one then print that record. row 1 field 2 and print that record.......
:confused:

Code:
Option Compare Database
Public Function test(Split1 As Variant)
On Error GoTo Err_Proc
 
'declare recordsets
    Dim rs As DAO.Recordset
    Dim db As Database
    Set db = CurrentDb
    Set rs = db.OpenRecordset("tbl WVL customer only")
    Dim strSQL As String
    Dim intFieldIndex As Integer
 
'look for records
    strSQL = "SELECT split1, split2, split3 FROM [tbl WVL customer only]"
     intFieldIndex = 1
       Set rs = CurrentDb.OpenRecordset(strSQL)
       If rs.RecordCount <> 0 Then
      rs.MoveFirst
    While Not rs.EOF
 
'temporary print to debug screen
    For i = 0 To 2
      'Debug.Print rs(i)
        Debug.Print rs.Fields(i)
       Next i
       rs.MoveNext
     Wend
    End If
 
'close all and cleanup
    rs.Close
    Set rs = Nothing
 
Tables have no intrinsic order. You must use a query with an order by clause if you want a specific record order.

BTW. Opening the recordset on the table in among your declarations is superfluous.
 
So i can remove the declaration Set rs = db.OpenRecordset("tbl WVL customer only")?
 

Users who are viewing this thread

Back
Top Bottom