"dkintheuk" <rm*******@firenet.uk.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
Hi all,
I am happy using the CurrentDB() reference to identify the local path
to my open database, but how do i programatically find the path to a
remote database? specifically, the database that i have my linked data
stored in?
Many thanks,
Rob.
You need to get it from the connect property of the tabledef object, as in
the function below. Be aware that this function does not check that the
backend really exists, nor will it complain if you pass the name of a table
which is not a straight-forward link to another Access database. For
example, if you gave the name of a table linked to a SQL Server database or
the name of local (real not linked) table, then the function would simply
return a zero-length string.
Public Function BackEndDb(LinkTable As String) As String
On Error GoTo Err_Handler
Dim dbs As DAO.Database
Dim tdf As DAO.TableDef
Set dbs = CurrentDb
Set tdf = dbs.TableDefs(LinkTable)
If Left(tdf.Connect, 10) = ";DATABASE=" Then
BackEndDb = Mid$(tdf.Connect, 11)
End If
Exit_Handler:
On Error Resume Next
If Not tdf Is Nothing Then
Set tdf = Nothing
End If
If Not dbs Is Nothing Then
Set dbs = Nothing
End If
Exit Function
Err_Handler:
MsgBox Err.Description, vbExclamation, "Error No: " & Err.Number
Resume Exit_Handler
End Function