Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

In Excel, I need to populate an ADO 1

Status
Not open for further replies.

SBendBuckeye

Programmer
May 22, 2002
2,166
US
In Excel, I need to populate an ADO recordset of exception data which is based on a query in an Access database. Do I need to instantiate an Access Application object to retrieve the data or can I use ADO by itself to do this?

If someone could point me, I would be grateful! Thank you!

Have a great day!

j2consulting@yahoo.com
 
Generally the DB needs to be running, so I would say yes.

Bastien

Any one have a techie job in Toronto, I need to work...being laid off sucks!
 
You don't need to instantiate the Access application. You can use ADO to connect to the database via ODBC.
Code:
Dim oConn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim strSQL As String

Set oConn = New ADODB.Connection
Set rst = New ADODB.Recordset
Set oConn = "Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\mydatabase.mdb;Uid=Admin;Pwd=;"
strSQL = "SELECT * FROM MyTable"
rst.Source = strSQL
rst.ActiveConnection = oConn
rst.CursorType = adOpenDynamic
rst.CursorLocation = adUseServer
rst.Open
Hope this helps.
 
Thank you Jables! That is exactly what I was looking for!

Have a great day!

j2consulting@yahoo.com
 
Haha, that's where I got the connection string that's in my post.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top