App path

J

John

Hi

How can I get the path of the current access app programmatically, within
the same app?

Thanks

Regards
 
W

Wayne Morgan

Application.CurrentProject.Path

will return the location of the adp or mdb file and

Application.CurrentProject.Name

will return the name of the file.
 
P

Pieter Wijnen

Function AppPath() As string
Dim ret as string
Ret = CurrentDb.Name
Ret = Left(Ret,Instr(Ret,Dir(Ret))-2)
AppPath=Ret
end Function

HTH
Pieter

PS always check http://www.mvps.org/access for utilities etc..
 
L

Larry Daugherty

Hi John,


Private Function GetDBDir() As String

' Purpose:
' Gets the directory of the currently open database.
' Based on code originally from Mike Gunderloy.
'
' From Access 97 Developer's Handbook
' by Litwin, Getz and Gilbert. (Sybex)
' Copyright 1997. All Rights Reserved.
'
' In:
' None
' Out:
' Return Value - The name of the directory as a string
' History:
' Created 09/13/94 pel; Last Modified 12/20/95 pel

On Error GoTo GetDBDirErr

Dim dbCurrent As Database
Dim strDbName As String
Dim strProcName As String

strProcName = "GetDBDir"

Set dbCurrent = CurrentDb
strDbName = dbCurrent.Name

Do While Right$(strDbName, 1) <> "\"
strDbName = Left$(strDbName, Len(strDbName) - 1)
Loop

GetDBDir = UCase$(strDbName)

GetDBDirDone:
On Error GoTo 0
Exit Function

GetDBDirErr:
Select Case Err
Case Else
MsgBox "Error#" & Err.Number & ": " & Err.Description, _
vbOKOnly + vbCritical, strProcName
Resume GetDBDirDone
End Select

End Function

If you don't already have it, I recommend getting The Access [yourversion]
Developer's Handbook by Ken Getz et alia.

HTH
 
Top