What is wrong with this DAO connection to the current DB?

R

rotor

Hello, I'm using Access 2002. Can someone please look at this code and tell me why it doesn't retrieve any rows from the table and show the correction(s) to make it work?

It seems to connect, but the recordset doesn't retrieve any rows (the table has 522 rows)

Dim db As DAO.Databas
Dim rs As DAO.Recordse
Dim strSQL As Strin
Dim lngRows As Lon
Dim lngCols As Lon

strSQL = "SELECT * FROM [TempTable1];

Set db = CurrentD
Set rs = db.OpenRecordset(strSQL

lngRows = rs.RecordCount -
lngCols = rs.Fields.Count -

MsgBox lngRows & " X " & lngCol

rs.Clos
db.Clos
Set rs = Nothin
Set db = Nothin

Thanks much in advance for the assistance.
 
R

Rick Brandt

rotor said:
Hello, I'm using Access 2002. Can someone please look at this code and
tell me why it doesn't retrieve any rows from the table and show the
correction(s) to make it work?
It seems to connect, but the recordset doesn't retrieve any rows (the
table has 522 rows):

RecordCount is not accurate unless you do a MoveLast first. Prior to that
it only indicates the records accessed so far.
 

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