PC Review


Reply
Thread Tools Rate Thread

Checking Linked Tables

 
 
RLN
Guest
Posts: n/a
 
      24th Jul 2008
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....
 
Reply With Quote
 
 
 
 
Klatuu
Guest
Posts: n/a
 
      24th Jul 2008
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

--
Dave Hargis, Microsoft Access MVP


"RLN" wrote:

> 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....

 
Reply With Quote
 
RLN
Guest
Posts: n/a
 
      24th Jul 2008
This worked great! thank you so much.


"Klatuu" wrote:

> 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
>
> --
> Dave Hargis, Microsoft Access MVP
>
>
> "RLN" wrote:
>
> > 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....

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Appending Records from Linked Tables to the *Real* Linked Tables tbl Microsoft Access Queries 2 22nd Jun 2006 01:42 AM
Linked Table Manager Not Showing List of Linked Tables Don Microsoft Access External Data 4 19th Oct 2005 02:21 PM
Names of Linked Tables do not show up in linked table manager =?Utf-8?B?S2VuIEo=?= Microsoft Access 4 3rd May 2005 12:00 AM
using linked table manager to update path on linked tables Nydia Microsoft Access 4 19th Aug 2003 11:33 PM
Changing paths of linked tables without Linked Table Manger Ilka Microsoft Access Database Table Design 0 30th Jul 2003 01:43 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:51 AM.