[AccessD] rs.RecordCount

Arthur Fuller fuller.artful at gmail.com
Sun Mar 24 13:01:01 CDT 2013


That clears it up for me. Thanks, Stuart. I'll go back to the old wisdom
LOL. Now where did I put my Intro to Alchemy book?

A.


On Sun, Mar 24, 2013 at 1:47 PM, Stuart McLachlan <stuart at lexacorp.com.pg>wrote:

> > Maybe it has something to do with the size of the recordset,
>
> That's the way I've always understood it.
>
> And a quick check reveals that it's still what MS says as at A2007:
>
>
> http://msdn.microsoft.com/en-us/library/office/bb208624%28v=office.12%29.aspx
>
> "Use the RecordCount property to find out how many records in a Recordset
> or TableDef
> object have been accessed. The RecordCount property doesn't indicate how
> many records
> are contained in a dynaset-, snapshot-, or forward-only-type Recordset
> object until all
> records have been accessed. Once the last record has been accessed, the
> RecordCount
> property indicates the total number of undeleted records in the Recordset
> or TableDef object.
> To force the last record to be accessed, use the MoveLast method on the
> Recordset object"
>
> --
> Stuart
>
> On 24 Mar 2013 at 13:15, Arthur Fuller wrote:
>
> > In my Sunday morning "Nothing is True, Question Everything" mood, I was
> > playing around with recordsets and wrote this little test of RecordCount.
> > Because I've always assumed it would be bad, coded something like this:
> >
> > <vba>
> > With rs
> >      If .bof or .eof then
> >          Msgbox
> >      end if
> >      .MoveLast
> >      .MoveFirst
> >      debug.print .RecordCount   ' or do something with it
> > End With
> > </vba>
> >
> > So instead I tried this:
> >
> > <vba>
> >     Dim intCount As Integer
> >     Dim rs As DAO.Recordset
> >     Set rs = Me.RecordsetClone
> >
> >     With rs
> >         'This suggests that the common movelast command is unnecessary.
> >         'The record count is the same before and after
> >         Debug.Print "Count Before Move: " & .RecordCount
> >         .MoveFirst
> >         .MoveLast
> >         Debug.Print "Count After Move: " & .RecordCount
> >         intCount = .RecordCount
> >     End With
> >     Me.txtCount = intCount
> >     rs.Close
> >     Set rs = Nothing
> > </vba>
> >
> > It appears that the recordset knows how large it is even without the
> > MoveLast command. Is the wisdom a myth? Or maybe that an old bug finally
> > got fixed? I'm using 2007, does that make a difference? Maybe it has
> > something to do with the size of the recordset, as in the case of a form
> > bound to a table with a million rows.
> >
> > Any thoughts?
> > --
> > Arthur
> > --
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > http://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
> >
>
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>



-- 
Arthur
Cell: 647.710.1314

Prediction is difficult, especially of the future.
  -- Niels Bohr


More information about the AccessD mailing list