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!

Microsoft Word Connecting To Access 2007 DB 1

Status
Not open for further replies.

chunter33

Programmer
May 16, 2011
44
CA
Hello, I was having a bit of trouble connecting to an access 2007 database. Before I get into the details, I'll give you a little background. I had a tool running off of Word in the old .doc format, and the code originally connected to an older access 97 database with the old mdb format. The connection code looked like so:

Set gobjConn = CreateObject("ADODB.Connection")

With gobjConn
.ConnectionString = "Driver=Microsoft Access Driver (*.mdb);DBQ=" & Application.ActiveDocument.Path & "\Triage.mdb;UID=Admin;PWD=;"
.Open
End With


The business was upgrading to Access 2007 so after converting the backend to accdb format I changed the code like so:


Set gobjConn = CreateObject("ADODB.Connection")

With gobjConn
.ConnectionString = "Driver=Microsoft Access Driver (*.accdb);DBQ=" & Application.ActiveDocument.Path & "\Triage.accdb;UID=Admin;PWD=;"
.Open
End With


However, this game the error message:

[Microsoft][ODBC Driver Manager]Data source name not found and no default driver specified

I thought it might have been because I was running the application in the older .doc format, so I converted it to .docm and tried again but it resulted in the same error message. Before anybody asks, yes the database exists on the specified path :)

Any ideas?
 


hi,

Try this...
Code:
    With gobjConn
        .ConnectionString = "Driver=Microsoft Access Driver [b](*.accdb,*.mdb)[/b];DBQ=" & Application.ActiveDocument.Path & "\Triage.accdb;UID=Admin;PWD=;"
        .Open
    End With

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top