Find application's directory

G

garyfehr

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
 
K

Ken Snell

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.
 
J

John Spencer (MVP)

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.
 
Top