I am new to using ADO for data access and I'm having some problems. I'm using VBA in Access 2002 to try and access some data that I have stored in a table. I'm trying to build a connection to the database that I have currently open and I'm not having any luck. Here is my code.
Dim conn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim fld As ADODB.Field
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=T:\Investments\Mgmtnli\Stat\2004 statbv\LE Recon\Recon Files\2Q\TestTCP.mdb;"
rst.Open "SELECT * FROM DP3_IMP", conn, adOpenForwardOnly, adLockReadOnly
The error comes with the conn.Open statement telling me that the file is already open and it's not allowed to be opened or locked. I could use DAO, which I'm familiar with, but I want to learn ADO. Also, I really don't want to have a string for where my file is located. I would rather just put in something equivalent to CurrentDB as the Data Source.
Thanks in advance,
Chris
Dim conn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim fld As ADODB.Field
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=T:\Investments\Mgmtnli\Stat\2004 statbv\LE Recon\Recon Files\2Q\TestTCP.mdb;"
rst.Open "SELECT * FROM DP3_IMP", conn, adOpenForwardOnly, adLockReadOnly
The error comes with the conn.Open statement telling me that the file is already open and it's not allowed to be opened or locked. I could use DAO, which I'm familiar with, but I want to learn ADO. Also, I really don't want to have a string for where my file is located. I would rather just put in something equivalent to CurrentDB as the Data Source.
Thanks in advance,
Chris