RecordCount Property (ADO)

J

JimS

I use ADO Recordsets...I have a simple one. Its code looks like:

Dim fc As New ADODB.Connection
Dim SCADALocrst As New ADODB.Recordset

Set fc = CurrentProject.Connection
SCADALocrst.Open "select * from SCADALoc order by SCADANbr", fc,
adOpenDynamic

varReturn = SysCmd(acSysCmdInitMeter, SCADALocrst.RecordCount)
---------
The table "SCADALoc" is a simple 15-item list I repopulate from scratch
within the program. I use docmd.runsql to delete *, then insert all 15 or so
items. This is done in another routine, so the table is not open from that
routine, which has completed its work.

The call to syscmd() fails because SCADALocrst.RecordCount = -1. I've
changed the cursortype, the access method, everything on the "open"
statement, and still get the same -1 record count.

I need the record count and cursor position with the record count to update
the syscmd meter. Neither property seems to be giving me useful information.

As a programmer, I've never made a mistake, so I'm sure it must be a bug in
Access... but on the off chance, I thought I'd ask if anyone has an idea why
I'm not getting useful returns.... ;)
 
C

Conrad

Jim,
Open the recordset adOpenKeyset. That should get you an accurate recordcount.

Conrad
 
T

Tim Ferguson

SCADALocrst.Open _
"select * from SCADALoc order by SCADANbr", _
fc, adOpenDynamic

varReturn = SysCmd(acSysCmdInitMeter, SCADALocrst.RecordCount)

countRecords = DCount("*", "SCADANbr")
varReturn = SysCmd(acSysCmdInitMeter, countRecords)


As a programmer, I've never made a mistake,

.... do you really mean that the way it sounds ..? <g>

HTH


Tim F
 
J

JimS

Thanks guys...

Yes, I was joking. I make more mistakes than I do non-mistakes.

Thanks again for the help....
 

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

Top