database file path

W

Wavequation

Is there a way to determine programmatically the directory path to the .mdb
file a database is based on?
 
D

Dirk Goldgar

Wavequation said:
Is there a way to determine programmatically the directory path to the
.mdb
file a database is based on?


CurrentProject.Path gives the folder.

CurrentProject.Name gives the file name.

CurrentDB.Name gives the full path and name of the database file, but
doesn't work in an ADP (Access Data Project).
 
M

Marshall Barton

Wavequation said:
Is there a way to determine programmatically the directory path to the .mdb
file a database is based on?


For the front end database:
CurrentProject.Path

The backend path\file is contained in the linked tables'
Connect property.
 
W

Wavequation

Thanks Marshall, actually, I've decided to use the backend. How exactly do I
access the connect property of a linked table?
Thanks!
 
K

kc-mass

Try something like:

Sub LinkedTableConnection()
Dim lngTable As Long
Dim db As Database
Set db = CurrentDb
For lngTable = 0 To db.TableDefs.Count - 1
If db.TableDefs(lngTable).Name = "tblYourLinkedTableName" Then
Debug.Print db.TableDefs(lngTable).Connect
End If
Next lngTable
Set db = Nothing
End Sub

'Obviously substitute your table name

Regards

Kevin
 
M

Marshall Barton

The DAO object structure for the full path to a linked table
in an mdb file is:

Mid(CurrentDb.TableDefs![linked table name].Connect, 11)
 
D

David H

Keep in mind that a front end can be linked to multiple back ends.

Marshall Barton said:
The DAO object structure for the full path to a linked table
in an mdb file is:

Mid(CurrentDb.TableDefs![linked table name].Connect, 11)
--
Marsh
MVP [MS Access]

Thanks Marshall, actually, I've decided to use the backend. How exactly do I
access the connect property of a linked table?
 

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

Top