[AccessD] MoveFirst needed in DAO?

Darryl Collins darryl at whittleconsulting.com.au
Wed Aug 8 18:39:33 CDT 2012


I would recommend you do that (movelast / movefirst) only if I need to know the precise count of records - otherwise in large recordsets you can get quite a delay whilst it works out how many records there are.  If you just need to know there is 'something' returned then "if rs.recordcount > 0 then" will do nicely.

Cheers
Darryl.

-----Original Message-----
From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of David McAfee
Sent: Thursday, 9 August 2012 7:28 AM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] MoveFirst needed in DAO?

I missed the beginning of this thread, so I might not totally understand what was being discussed here.

Am I the only one that makes a habit of always moving last then first before getting a count?

if Not rs.BOF and not rs.EOF
   rs.MoveLast
   rs.MoveFirst
   debug.print rs.recordcount
else
   'empty recordset
end if

On Wed, Aug 8, 2012 at 2:12 PM, Jim Lawrence <accessd at shaw.ca> wrote:

> I knew it was a problem with ADO type recordsets which may just start 
> at the bottom instead of the top. I think DAO type recordsets always 
> seem to start at the top unless there was some intermediate 
> processing.
>
> OTOH using the style, you displayed, would work for any recordset so a 
> developer could create simple universal recordset handling code and 
> classes.
>
> Jim
>
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com





More information about the AccessD mailing list