DAO recordset not returning the correct number of records (1 Viewer)

cpampas

Registered User.
Local time
Today, 01:10
Joined
Jul 23, 2012
Messages
218
Hello,
I wonder if someone can help me with this:

I created a sql string to build a query wich works fine . the end result is that I have a query ( qryBuscaB), that returns 11 records
I then want to access every record in the query, like this

Code:
Dim db As Database
Dim rst As Recordset


Set db = CurrentDb()
Set rst = db.OpenRecordset("qryBuscaB", dbOpenDynaset)


MsgBox (rst.RecordCount) ' here I get 1079 and not 11 as it should
  With rst
          Do While Not .EOF    ' once i get to the last record it continues to the first one again
                    Debug.Print !descMaq & "   "; !precoMaq & "   " & !Pais
            .MoveNext
          Loop
  End With

Any thoughts ?
 

bob fitz

AWF VIP
Local time
Today, 09:10
Joined
May 23, 2011
Messages
4,719
Try:
rst.MoveLast
rst.MoveFirst
MsgBox (rst.RecordCount) ' here I get 1079 and not 11 as it should
 

cpampas

Registered User.
Local time
Today, 01:10
Joined
Jul 23, 2012
Messages
218
Many thanks, it works great
 

missinglinq

AWF VIP
Local time
Today, 04:10
Joined
Jun 20, 2003
Messages
6,423
The problem is/was that the Access Gnomes don't always load an entire recordset...Bob'd code forces it to with the rst.MoveLast.

Linq ;0)>
 

Users who are viewing this thread

Top Bottom