Connection Obect for Two Paths

  • Thread starter Thread starter Tod
  • Start date Start date
T

Tod

I have a server that contains a database and a workbook.
The workbook code uses ADO to connect to the database, run
a query and return the results to the worksheet.

'Where cn is my ADODB.Connection
"cn.Open "Driver={Microsoft Access Driver
(*.mdb)};Dbq=C:\DatabasePath\DatabaseName.mdb;"

This works fine.

On another computer, I have a folder that is shared to
that folder on the server. I want to open the same
workbook from this shared folder and run the code. I'd
need to modify the statement to something like this:

'Where cn is my ADODB.Connection and V is the mapped drive
letter to DatabasePath.
"cn.Open "Driver={Microsoft Access Driver
(*.mdb)};Dbq=V:\DatabaseName.mdb;"

The problem is I'd like to have my code detect the path to
the database (depending from where I'm opening the
workbook) and set up the string accordingly.

Any suggestions?

tod
 
Use this instead... will work no matter what machine your on.

\\databaseserver\databasepath\databasename.mdb

Dennis
 

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

Back
Top