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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening an Access database using VBA in Excel

Status
Not open for further replies.

Deco1

Programmer
Mar 15, 2002
3
0
0
GB
I writing a VBA procedure in Excel. Part of the function is to open an Access database in order to populate certain tables. I'm having problems opening the databse. Can any of you experts out there give me any help??

Cheers
 
Hi Deco,

Off the top of my head I am writing you an example. If
you need more info, just let me know.

I hope this helps you.

Kim
Code:
Dim db As Database
Dim rst As Recordset
Set db = Workspaces(0).OpenDatabase("accessdb.mdb")
Set rst = db.OpenRecordset("mytable", dbOpenDynaset)
rst.AddNew
  ' Do your thing here
rst.Update
rst.Close
db.Close
set rst = Nothing
set db = Nothing
 
Thanks kim,

I've got it working now.

In case anyone else is interested in the code I've posted it below.

Deco

Dim strPath As String
Dim objAccess As Object

strPath = "G:\reinledg\Midnight\697LPC\LPCCashImport.mdb"
Set objAccess = GetObject(strPath)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top