Find application's directory

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Ok, I'm an idiot - in VBA, how do I find the directory that my database is located in? VBA.FileSystem.CurDir$ returns the working directory, which is not the same.
Thanks,
Gary
 
CurrentProject.Path


--

Ken Snell
<MS ACCESS MVP>

garyfehr said:
Ok, I'm an idiot - in VBA, how do I find the directory that my database is
located in? VBA.FileSystem.CurDir$ returns the working directory, which is
not the same.
 
Full path to the file including the name of the database is

CurrentDb().Name

You can strip the name off the end to get the directory.

Since you don't say which version of Access, try

Dim strPath as String

strPath = currentDb().Name
strPath = Left(strPath,Len(strPath)-Len(Dir(StrPath))-1)

Adjust the minus one on whether you want to include the final slash or not.
 
Back
Top