Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2002
    Location
    Hamburg, Germany
    Posts
    14

    Question Unanswered: How to get the database's path

    Hi all,

    I'm wondering how I can retrieve the full path to my Access application from a VBA script. I tried CurDir() but that returns the path to my documents which is not where the database is located...

    Thanks for your help,
    Ulf Moehring

  2. #2
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    This funciton would return the path of every table in your application....

    Dim tdf As TableDef, strPath As String
    For Each tdf In CurrentDb.TableDefs
    strPath = tdf.Connect
    Debug.Print strPath
    Next

  3. #3
    Join Date
    Nov 2002
    Location
    Hamburg, Germany
    Posts
    14
    I use two different types of tables - regular access tables and tables linked to an oracle server via odbc. In the first case I get an empty string when trying the above code and in the second case I get the ODBC-connect string. I'm running the VBA code as module inside that Access application maybe that's why?

    I need this because my access app gets moved around quite a bit and updating path names manually can get really tiresome...

  4. #4
    Join Date
    Nov 2002
    Location
    Hamburg, Germany
    Posts
    14

    Talking

    Now I did this which works fine. A lot easier than I thought:

    Dim i As Integer
    Dim DBName As String
    DBName = CurrentDb.Name
    i = Len(DBName)

    Do While Mid(DBName, i, 1) <> "\"
    i = i - 1
    Loop

    Directory = Left(DBName, i)

  5. #5
    Join Date
    Jul 2003
    Posts
    6
    Why aren't you just using CurrentProject.Path and CurrentProject.Name to get these values?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •