1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| Function GetLinkedDB(strLinkedTable As String) As String
Dim strConn As String, strSceDBPathName As String
Dim db As DAO.Database, tdef As DAO.TableDef
Dim p1 As Long, p2 As Long
Set db = CurrentDb
Set tdef = db.TableDefs(strLinkedTable)
If (tdef.Attributes And dbAttachedTable) = dbAttachedTable Then
strConn = tdef.Connect
' Le nom complet de la base de données source commence
' après "DATABASE="
p1 = InStr(1, strConn, "DATABASE=", vbTextCompare)
If p1 > 0 Then
p2 = InStr(p1, strConn, ";")
' Il se termine au premier point-virgule (;) suivant
' ou à la fin de la chaîne de connexion
If p2 = 0 Then p2 = Len(strConn) + 1
strSceDBPathName = Mid(strConn, p1 + 9, p2 - p1 - 9)
GetLinkedDB = strSceDBPathName
End If
End If
End Function |
Partager