Get number of records in a table
Hi,
Newbie (complete idiot wrt to databases) here. I have a simple Access table (Table1) with 2 records. I trying to use an an ADODB connection (hope that makes sense) to write to this database. I need to know how many rows there are so when I right the next record I can define the number for the autonumber key field.
This is my code:
'Define a table recordset.
Set rsTable = .OpenSchema(adSchemaTables, Array(Empty, Empty, "Table1"))
Debug.Print rsTable.RecordCount
Do While Not rsTable.EOF
lngRows = lngRows + 1
rsTable.MoveNext
Loop
rsTable.MoveFirst
.RecordCount is returning -1
The Do ... While only counts to 1
What am I doing wrong? Thanks.