Finding the path of the directory which the currently access file is in

P

Pieter Wijnen

Quite simple

Function AppPath() As string
' will not work if dir contains db name ie C:\db1.mdb\db1.mdb
Dim Db AS DAO.Database
Set Db = Access.CurrentDb
AppPath = Db.Name
AppPath = Left(AppPath,Instr(AppPath,Dir(AppPath))-2)
Set db = nothing
End Function

HTH

Pieter
 
R

RoyVidar

Amir wrote in message said:
Hi!

Guess I have an Access file named db1.mdb, placed on my desktop, and my
username is 'Admin'.

What code should I use in order to put this file's directory path (I mean the
path of the currently active database file, e.g. "C:\Documents and
Settings\Admin\Desktop") into the variable strMyPath ?

Regards,
Amir.

In 2000+ versions, you can use

currentproject.path
 
A

Amir

Hi!

Guess I have an Access file named db1.mdb, placed on my desktop, and my
username is 'Admin'.

What code should I use in order to put this file's directory path (I mean
the path of the currently active database file, e.g. "C:\Documents and
Settings\Admin\Desktop") into the variable strMyPath ?

Regards,
Amir.
 
A

Amir

Hi!

Thank you very much!

Kind Regards.


Pieter Wijnen said:
Quite simple

Function AppPath() As string
' will not work if dir contains db name ie C:\db1.mdb\db1.mdb
Dim Db AS DAO.Database
Set Db = Access.CurrentDb
AppPath = Db.Name
AppPath = Left(AppPath,Instr(AppPath,Dir(AppPath))-2)
Set db = nothing
End Function

HTH

Pieter
 
Top