|
Getting the path to a Linked Table
If you have a Linked Table in Access, and you want to know the path and name of the Database that it is located in, then you can check the TableDef's Connect property. A generic function for this is below:
Function fLinkedTablePath1(strTableName As String) As String
fLinkedTablePath1 = Mid(CurrentDb.TableDefs(strTable).Connect, InStr(CurrentDb.TableDefs(strTableName).Connect, ";DATABASE=") + 10)
End Function
If you are only ever going to be concerned with tables that are linked from another Access database, then, rather than finding the start of the path in the Connect string, you can just use the position:
Function fLinkedTablePath2(strTableName As String) As String
fLinkedTablePath2 = Mid(CurrentDb.TableDefs(strTable).Connect, 11)
End Function |
|