recordcount = -1???

  • Thread starter Thread starter SirPoonga
  • Start date Start date
S

SirPoonga

I assign rs.recordcount from a record set to a variable. It returns -1
when there are records being returned. Any ideas?
 
That means that there is at least one record in the recordset. If there are
no records, the .RecordCount value would be zero.

Thus, check the .RecordCount value. If not equal to zero, the recordset
contains at least one record. To get the actual count, move the recordset to
the last record and then read the .RecordCount value.
 
I tried that movelast thing. I get an error that "Rowset does not
support fetching backward"
 
This happens for certain types of ADO recordsets (not DAO), and my
understanding is that the -1 means the number of "undefined".

If you need the RecordCount, you will need to change the type of recordset
you open.
 
When you open an ADO recordset using default values for cursor type, cursor
location, and record locking, you get a read-only, forward only recordset.
You need to specify those optional arguments if you want a different type of
recordset.

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
What options should I be using then?
I'm just going defaults.
Dim rs As Recordset
Set rs = New ADODB.Recordset
rs.Open sqlcmd, CurrentProject.Connection
 
Determining the most efficient combination of settings to use can be quite a
complex question, depending on what exactly you need to do with the
recordset, the size of the recordset, and possibly other factors. However,
to resolve the immediate problem, try using a CursorLocation of adUseClient,
a CursorType of adOpenDynamic, and a LockType of adLockOptimistic.

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top