Returning Access' working directory

  • Thread starter Thread starter Max Moor
  • Start date Start date
M

Max Moor

Hi All,
Is there a way to get, from VB code, the path to the directory in
which the current database was opened?

- Max
 
Private Sub GetMyPath
Dim dbs As DAO.Database, strPath As String
Set dbs = CurrentDb
strPath = dbs.Name
End Sub
 
?CurrentProject.Path
D:\Thien

If you use A97, it is slightly more complicated since CurrentProject does
not exist in A97 & you need to use CurrentDb.Name to derive the path to the
directory (CurrentDb.Name gives the full pathname of the database, NOT just
the directory).

HTH
Van T. Dinh
MVP (Access)
 
Private Sub GetMyPath
Dim dbs As DAO.Database, strPath As String
Set dbs = CurrentDb
strPath = dbs.Name
End Sub

Hi Mike,

Thanks for the answer. I gave it a whirl, and found out I didn't
have a reference to DAO set even. I dug through ADO stuff and found
another one that seems to work. I thought I'd pass it on back to you.
I get the full path with:

Application.CurrentProject.FullName

just the path with:

Application.CurrentProject.Path

and just the DB name with:

Application.CurrentProject.Name

Again, thanks for the answer.

- Max
 
Back
Top