Linked Table Record Count correct?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've been learning about linked tables ( splitting my mdb's to front & back
end) and I remember reading some place that the record count property always
comes out -1. I'm not sure if they meant actualcount -1 or the value -1. I
use recordcount in decision making a couple of times and I was wondering if
anybody knows about a problem with this. Maybe it was an old article and the
problem has been fixed.?. Can someone please let me know if they've heard of
this b/4 and if there is a solution?? Thanx
 
To get an accurate count of the number of records in a recordset, you should
use something like:
rs.MoveLast
lngRecordCount = rs.RecordCount
rs.MoveFirst
 
When linked to SQL Server, using ODBC, there are some
kinds of recordsets that will not and do not return
a recordcount: all you get is -1.

All other recordsets return 0 (empty), 1 (1 or more
records), or n (n records have been read from the
database).

If your recordset has a record count of 1 or more,
move to the end of the recordset to make sure all
records are read.

If your recordset has a record count of -1, choose
a different kind of recordset to get a record count.

(david)
 
Thanx for the input guys!! It must have been that special case in ODBC that
I remembered reading about. I have read and do know that to get an accurate
recordcount you need to populate the recordset first ( I think it said the
records weren't actually made up until you needed one ??) and of course
movelast would do that. So you're saying that if I'm using an ordinary
recordset in Jet (nothing odd) that it will always return the correct # of
records?? Thanx again
 
Gilbert said:
Thanx for the input guys!! It must have been that special case in
ODBC that I remembered reading about. I have read and do know that
to get an accurate recordcount you need to populate the recordset
first ( I think it said the records weren't actually made up until
you needed one ??) and of course movelast would do that. So you're
saying that if I'm using an ordinary recordset in Jet (nothing odd)
that it will always return the correct # of records?? Thanx again

My understanding is that the requirement to do a MoveLast is NOT limited to ODBC
tables. It is more likely to be an issue on larger tables, but I certainly
wouldn't trust the RecordCount in any situation without issuing a MoveLast
first.
 
Well, except if somebody just entered the record:
then you have to wait until the record is written
back to the database, then wait until it is read
from the database into your record cache.
It may take 5 or more seconds until you get the
new record, and of course you won't be able to
read it or count it until you get it. But yes,
the record count always returns the number of
records you currently have - and if you move last
you always have all the records you can find.

(david)
 
Back
Top