Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with Rs.RecordCount

Status
Not open for further replies.

ssreddy

Programmer
Aug 13, 2001
4
HK
I want to count the number of records present in a table. So, for that I gave the statement as :

qosSql = "SELECT * From tblMonthlySub"

qosRs.Open qosSql, qosConn, 3, 3, 1

MsgBox (qosRs.RecordCount)

although there are more than 300 records present in the table but it's always showing '-1' in the message box. Can anybody suggest what is the problem???? Thanks a lot.
 
Before doing your recordcount, do:

qosRs.MoveLast
qosRs.MoveFirst

 
If ALL you want is the recordcount:

qosSql = "SELECT Count(*) As RecCnt From tblMonthlySub"

qosRs.Open qosSql, qosConn, 3, 3, 1

MsgBox (qosRs.RecCnt)


Note: The MoveLast method mentioned in the other response will not work. the return ("-1") indicates the recordset does not support the property. I 'suspect' you are using ADO, where ".RecordCount" does not (usually?) work.


MichaelRed
mred@att.net

There is never time to do it right but there is always time to do it over
 
Check out your cursor-typ. Use a keyset-cursor instead of static or forward only(default). That will solve your problem.

markus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top