Active DB filepath

  • Thread starter Thread starter paxdak
  • Start date Start date
P

paxdak

In a module, how to you return the active DB filepath?

In Excel, this can be determined by ActiveWorkbook.Path

I looked in the CurrentDB, but didn't see any filepath properties.
Any help would be appreciated.
 
In a module, how to you return the active DB filepath?

In Excel, this can be determined by ActiveWorkbook.Path

I looked in the CurrentDB, but didn't see any filepath properties.
Any help would be appreciated.


Somewhat unintuitive, but the path is stored in the 'name' property, eg:

strDbPath = Currentdb.Name
 
Use the Name property of CurrentDB:

CurrentDB.Name

or the Fullname property of CurrentProject

This will return the entire path including the name, so you can remove the
name and leave just the path, like this:

Function getpath(Filename As String) As String
getpath = (Mid(Filename, 1, Len(Filename) - Len(Dir(Filename))))
End Function

I always create a little general function as above. Call it like this:

MyPath = getpath(CurrentDB.Name)

or

MyPath = getpath(CurrentProject.Fullname)

--
--Roger Carlson
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
 
CurrentDb.Name will give you the complete path and name of the current
database.

Left(CurrentDb.Name, InStrRev(CurrentDb.Name, "\"))
will give you just the path.

Alice
 
If you use A2K or later:

CurrentProject.Path

gives you the full path of the database without the database name.

HTH
Van T. Dinh
MVP (Access)
 
Back
Top