App path

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

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

Thanks

Regards
 
Application.CurrentProject.Path

will return the location of the adp or mdb file and

Application.CurrentProject.Name

will return the name of the file.
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top