Returning Access' working directory

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
 
M

Mike M.T.

Private Sub GetMyPath
Dim dbs As DAO.Database, strPath As String
Set dbs = CurrentDb
strPath = dbs.Name
End Sub
 
V

Van T. Dinh

?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)
 
M

Max Moor

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
 

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