recordset.count behaves strange

  • Thread starter Thread starter Hajo
  • Start date Start date
H

Hajo

Hi,

When I execute the following code, tmp contains only 1. Actually it should
be 4.
1. Dim tmp As Integer
2. tmp = Me.Recordset.RecordCount

Now, when I set a breakpoint on the 2nd line, tmp will has the correct value
of 4.

Why is that so and what can I do to change that?

Thank you,
Hajo
 
You didn't give much detail, but generally the recordcount is only accurate
once you've specifically forced loading all the records. Try something like:

With Me.Recordset
.moveLast
.moveFirst
temp = .RecordCount
End With
 
On Sun, 25 Jan 2009 21:29:36 -0500, "Paul Shapiro"

Since you can't MoveLast on an empty recordset you can also write:

With Me.Recordset
if .RecordCount = 0 then temp = 0
else
.moveLast
.moveFirst
temp = .RecordCount
end if
End With

-Tom.
Microsoft Access MVP
 
Back
Top