Using ADO from within access

P

Pete Davis

From a piece of sample VBA code in Access, I've seen that with DAO, you can
do something like:

Dim db As DAO.Database
db = CurrentDb

Is there an equivalent for ADO? I know ADO doesn't have a database object.

Basically, I want to use the current database for my work and I need to use
ADO.

Thanks.

Pete
 
P

Peter Hoyle

Dim cnn As ADODB.Connection
Dim rs As New ADODB.Recordset
Dim strSQL As String

Set cnn = CurrentProject.Connection
strSQL = "SELECT * FROM tblMyTable"
rs.Open strSQL, cnn
rs.MoveFirst

etc.

Cheers,
Peter
 
P

Pete Davis

Thank you both very much. That was a great help.

Pete

--
http://www.petedavis.net

Peter Hoyle said:
Dim cnn As ADODB.Connection
Dim rs As New ADODB.Recordset
Dim strSQL As String

Set cnn = CurrentProject.Connection
strSQL = "SELECT * FROM tblMyTable"
rs.Open strSQL, cnn
rs.MoveFirst

etc.

Cheers,
Peter
 

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

Similar Threads

Result SQL server(2000) differs between ADO and DAO 2
DAO IS DED 16
DAO vs ADO 5
vb6 ado access report 1
DAO to ADO 1
Read ADO with DAO 4
Using "like" query from and external link to Access 1
ado upgrade or dao 3

Top