Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: RecordSetClone.RecordCount vs RecordSet.RecordCount

305 views
Skip to first unread message

Marshall Barton

unread,
Mar 3, 2009, 6:19:34 PM3/3/09
to
Steve S wrote:

>1. Researching a problem with RecordCount I see references to both Recordset
>and recordsetclone. which one should I use when and why?
>
>2. The use of Recordcount as the controlsource of a textbox on a form
>causes a #Name error in AC2003. this same code works fine in AC2000.
>RecordCount used in form modules seem to work OK in both versions.
>
>Anyone have an idea what the problem might be?


All of these worked for me in an A2003 text box expression
=Form.Recordset.RecordCount
=Recordset.RecordCount
=Form.RecordsetClone.RecordCount
=RecordsetClone.RecordCount

The clone of a recordset is a different recordset (connected
to the same data) so they can have different current
records. E.g. you can search the clone for a record without
messing with the form's current record. You need to know
when you should use the clone and when it is ok to use the
form's recordset directly.

Note that a form's RecordsetClone is automatically created
so there is little or no need to use Me.Recordset.Clone,
which will create a new recordset.

--
Marsh
MVP [MS Access]

Paul Shapiro

unread,
Mar 3, 2009, 8:48:26 PM3/3/09
to
If you're working with Access 2007, Allen Browne has documented a bug with
RecordsetClone.RecordCount that was still not fixed as of SP1.
http://allenbrowne.com/Access2007.html#Bugs

"Marshall Barton" <marsh...@wowway.com> wrote in message
news:qsdrq45ebo24ne12g...@4ax.com...

Marshall Barton

unread,
Mar 4, 2009, 9:54:02 AM3/4/09
to
Steve S wrote:

>1. Researching a problem with RecordCount I see references to both Recordset
>and recordsetclone. which one should I use when and why?
>
>2. The use of Recordcount as the controlsource of a textbox on a form
>causes a #Name error in AC2003. this same code works fine in AC2000.
>RecordCount used in form modules seem to work OK in both versions.
>
>Anyone have an idea what the problem might be?


This is not related to your posted question, but another
important point about RecordCount is that it returns the
*number of records accessed*. For all but table type
recordsets, this means it is only guaranteed to be >0 if
there are any records or 0 if there are no records. To
force all of a form's records to be "accessed" so
RecordCount returns the count of all of the form's records,
you would have to use a line of code (in the forms Load
event?):
Me.RecordsetClone.MoveLast
and, if you use RecordCount in a text box expression, you
probably should also requery the *text box*

0 new messages