RecordCount method
am 25.01.2008 16:14:46 von qqmbers
May be it will help someone.
I faced the strange problem with RecordCount property of cloned
Recordset within the Current event handler. The RecordCount value was
correct every time I had diagnostic message boxes turned on or when I
debugged the handler step by step. And these values became incorrect
in normal mode (to be exact they became wrong after the first
occurrence of "no records" case). I tried to use MoveFirst and
MoveLast combination, but it required the error handler for the "no
records" case. Then I tried to use EOF/BOF-based solution but these
properties behave in the same way. I solved my problem in the
following way - I just added invoke of Requery method just after
creation of recordset. For my case it looks like that:
Set rst=Me.RecordsetClone
rst.Requery ' This is the "magic" that helped
trec=rst.RecordCount
Re: RecordCount method
am 28.01.2008 22:12:12 von Dominic Vella
I would normally use both
------------------------------
Set rst=Me.RecordsetClone
If Not rst.EOF Then
rst.MoveLast
rst.MoveFirst
intRecCount=rst.RecordCount
End If
---------------------------
I personally prefer not to requery as it can be slow on complicated queries
and/or larger tables.
I hope this RecordCount issue was fixed in Access2007.
wrote in message
news:5be1d318-498f-4807-8b97-17c09eef5cd7@v46g2000hsv.google groups.com...
> May be it will help someone.
> I faced the strange problem with RecordCount property of cloned
> Recordset within the Current event handler. The RecordCount value was
> correct every time I had diagnostic message boxes turned on or when I
> debugged the handler step by step. And these values became incorrect
> in normal mode (to be exact they became wrong after the first
> occurrence of "no records" case). I tried to use MoveFirst and
> MoveLast combination, but it required the error handler for the "no
> records" case. Then I tried to use EOF/BOF-based solution but these
> properties behave in the same way. I solved my problem in the
> following way - I just added invoke of Requery method just after
> creation of recordset. For my case it looks like that:
> Set rst=Me.RecordsetClone
> rst.Requery ' This is the "magic" that helped
> trec=rst.RecordCount