Checking Linked Tables

R

RLN

I have this code I got off of the web to change the table links:
<begincode>
Public Sub RelinkTables(prmNewDBPath As String)
'Original Code
Dim Dbs As Database
Dim Tdf As TableDef
Dim Tdfs As TableDefs
Dim strMsg As String
Set Dbs = CurrentDb
Set Tdfs = Dbs.TableDefs

'Loop through the tables collection
For Each Tdf In Tdfs
If Left(Tdf.SourceTableName, 3) = "tbl" Then
Tdf.Connect = ";DATABASE=" & prmNewDBPath
Tdf.RefreshLink
strMsg = strMsg & "Linked: " & prmNewDBPath & "--" &
Tdf.SourceTableName & vbCrLf
End If
Next

MsgBox " Tables Linked successfully: " & vbCrLf & vbCrLf & strMsg,
vbOKOnly + vbInformation, "ReLinkTables"
End Sub
<end code>

Before I run this to actually change the links to another .mdb, I would like
to see what db the tables are linked to before they are changed. Is there a
simple way to check this?

Thanks....
 
K

Klatuu

The connect property of the tabledef object contains the path to the mdb that
contains the linked table.

So in your code Here:
For Each Tdf In Tdfs
Debug.Print "Table " & tdf.Name & " Connection is " & tdf.Connect
If Left(Tdf.SourceTableName, 3) = "tbl" Then
 
R

RLN

This worked great! thank you so much.


Klatuu said:
The connect property of the tabledef object contains the path to the mdb that
contains the linked table.

So in your code Here:
For Each Tdf In Tdfs
Debug.Print "Table " & tdf.Name & " Connection is " & tdf.Connect
If Left(Tdf.SourceTableName, 3) = "tbl" Then
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top