ADO Not Opening Recordset

L

Leo

Help: I am just starting at a new company, and am having issues getting
Access to perform ADO.recordset operations correctly. And, there is no
"go-to" person here. I am just trying to use automation to make my life
easier. The code below returns an empty recordset ("-1" on the message box
which I added as a test). It finishes with an error message

I assume that I am just missing a library. I do have the MS ADO 2.8 and VBA
libraries selected in references. My version is Access 2003.

Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset

With rs
.ActiveConnection = CurrentProject.Connection
.CursorType = adOpenDynamic
.LockType = adLockPessimistic
.Open "SELECT * FROM tblNorthstar;"
End With
MsgBox rs.RecordCount

rs.close
Set rs = Nothing
 
A

AccessVandal via AccessMonster.com

What was the error message and at which line?
Help: I am just starting at a new company, and am having issues getting
Access to perform ADO.recordset operations correctly. And, there is no
"go-to" person here. I am just trying to use automation to make my life
easier. The code below returns an empty recordset ("-1" on the message box
which I added as a test). It finishes with an error message

I assume that I am just missing a library. I do have the MS ADO 2.8 and VBA
libraries selected in references. My version is Access 2003.

Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset

With rs
.ActiveConnection = CurrentProject.Connection
.CursorType = adOpenDynamic
.LockType = adLockPessimistic
.Open "SELECT * FROM tblNorthstar;"
End With
MsgBox rs.RecordCount

rs.close
Set rs = Nothing
 
M

mie

Try remove rs.close
just leave Set rs=Nothing.

I dont know why, but sometime it happen to me. I'm using Access 2007 and it
work.
 

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