| | |
|
|
|
App path |
| message from John on 7 May 2004 |
Hi
How can I get the path of the current access app programmatically, within
the same app?
Thanks
Regards
|
| Larry Daugherty replied to John on 7 May 2004 |
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
|
| Wayne Morgan replied to John on 7 May 2004 |
Application.CurrentProject.Path
will return the location of the adp or mdb file and
Application.CurrentProject.Name
will return the name of the file.
|
| Pieter Wijnen replied to John on 7 May 2004 |
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..
"John" <john@nospam.infovis.co.uk> wrote in message
news:OYI5hr$MEHA.556@tk2msftngp13.phx.gbl...
|
|
Archived message: App path (Microsoft Access)