Roger's Access Library Homepage
Forum Home Forum Home > Other Download Libraries > MS Access MVP Libraries > Long, Crystal
  New Posts New Posts RSS Feed - Get Path\Filename of Back End
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Please consider donating $1 per sample downloaded, (find out why here)

Get Path\Filename of Back End

 Post Reply Post Reply
Crystal Long View Drop Down
Microsoft MVP
Microsoft MVP

Joined: 21 May 2012
Location: Colorado
Status: Offline
Points: 35
Post Options Post Options   Thanks (0) Thanks(0)   Quote Crystal Long Quote  Post ReplyReply Direct Link To This Post Topic: Get Path\Filename of Back End
    Posted: 03 Nov 2013 at 11:00am
Given a table name, this function returns the path\filename of the Back End database if it is Access:

Function GetAccessBE_PathFilename(pTableName As String) As String

   '  the file path and file name of the BE database
   '  "" if the table is not linked
   On Error GoTo Proc_Err
   Dim db As dao.Database _
      , tdf As dao.TableDef
   GetAccessBE_PathFilename = ""
   Set db = CurrentDb
   Set tdf = db.TableDefs(pTableName)
   If Len(tdf.Connect) = 0 Then
      GoTo Proc_Exit
   End If
   ' look at Connect string - Database Type is the first thing specified
   ' if the BE is Access
   If InStr(tdf.Connect, ";DATABASE=") <> 1 Then
      GoTo Proc_Exit
   End If
   GetAccessBE_PathFilename = Mid(tdf.Connect, 11)
   On Error Resume Next
   Set tdf = Nothing
   Set db = Nothing
   Exit Function
   MsgBox Err.Description, , _
        "ERROR " & Err.Number _
        & "   GetAccessBE_PathFilename"

   Resume Proc_Exit
End Function

to test, you can type this into the Immediate window:
? GetAccessBE_PathFilename("MyLinkedTableName")

MyLinkedTableName is the name of a table that is linked to an Access back end

Warm Regards,

My Analyzer
... the ultimate Data Dictionary Tool (Free download. As of November 2013, last update was October 2013)

   (: have an awesome day :)

Warm Regards,
Microsoft MVP
Remote Training & Programming
Let's Connect and Build Together
~have an awesome day ~
Back to Top
Sponsored Links

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.03
Copyright ©2001-2019 Web Wiz Ltd.