Hi,
I use VB6 with Access. I have 4 records in my DBF file. When i do Recordcount, it says that i had -1 record. Why not 4? Help please
Thanks

Dim Conn As New ADODB.Connection
Dim Rs As New ADODB.Recordset
Dim Query As String

Private Sub Form_Load()

Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\Projects\VB 6\Listbox\Database.mdb;Persist Security Info=False"
Conn.Open

Query = "SELECT * FROM Table1"
Set Rs = Conn.Execute(Query)

List1.AddItem Rs.RecordCount
End Sub

Recommended Answers

All 2 Replies

Hi,
I use VB6 with Access. I have 4 records in my DBF file. When i do Recordcount, it says that i had -1 record. Why not 4? Help please
Thanks

Dim Conn As New ADODB.Connection
Dim Rs As New ADODB.Recordset
Dim Query As String

Private Sub Form_Load()

Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\Projects\VB 6\Listbox\Database.mdb;Persist Security Info=False"
Conn.Open

Query = "SELECT * FROM Table1"
Set Rs = Conn.Execute(Query)

List1.AddItem Rs.RecordCount
End Sub

try this
dim rs as new adodb.recordset

rs.CursorLocation = adUseClient
rs.open "Select * from table",conn
msgbox rs.recordcount
set rs=nothing

try using rs.movelast
and then use rs.RecordCount

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.