RecordSetClone.RecordCount vs RecordSet.RecordCount

RecordSetClone.RecordCount vs RecordSet.RecordCount

Post by U3RldmUgU » Thu, 05 Mar 2009 06:34:08


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?
--
Steve S
 
 
 

RecordSetClone.RecordCount vs RecordSet.RecordCount

Post by Marshall B » Thu, 05 Mar 2009 08:19:34


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]

 
 
 

RecordSetClone.RecordCount vs RecordSet.RecordCount

Post by Paul Shapi » Thu, 05 Mar 2009 10:48:26

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://www.yqcomputer.com/ #Bugs
 
 
 

RecordSetClone.RecordCount vs RecordSet.RecordCount

Post by Marshall B » Thu, 05 Mar 2009 23:54:02


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*

--
Marsh
MVP [MS Access]