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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with determining number of records

Status
Not open for further replies.

paco2001

Technical User
Aug 21, 2001
10
US
I use the data control when using ms access with vb 6. But I'm having trouble trying to find out how many records there might be in a table. I run into problems when I check for recordcount and there are no records in the table I know that you movelast which should give the total recordcount. But if there are no records in the table then the recordcount isn't reliable. Any advice? Thanks.
 
If Not rs.EOF And Not rs.BOF Then
rs.MoveLast
if rs.RecordCount ......
Tim

Remember the KISS principle:
Keep It Simple, Stupid!
 
Hi,

If the recordset supports the .recordcount property denpends on the crusortype. Use "static" if you want to use the .recordcount. I have, however, seen people complain that even with a static cursor type they have problems with .recordcount. It probabply depends on the provider.
A foolproof method is:

---------------------------------------------------
dim Rst as ADODB.recordset

Set Rst = new ADODB.recordset
Rst.open "SELECT count(*) FROM MyTable", MyCon

msgbox(cstr(Rst.fields(0)) & " records in MyTable")
Rst.close
set Rst = nothing
---------------------------------------------------


Sunaj
 
Also, the MoveLast method is not required to generate a recordcount in an ADO recordset. The previous responder brought up a good point. Ensure that the recordset lock type supports the Recordcount property.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top