View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
tod tod is offline
external usenet poster
 
Posts: 114
Default Connection Obect for Two Paths

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