423,485 Members | 1,664 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,485 IT Pros & Developers. It's quick & easy.

File name for linked tables

P: 2
Hi, Does anyone know how I can get the file name for the linked tables?
I have linked the tables and renamed them. I am able to get the renamed name shown on table tab, but not the actual FILE NAME that i originaly linked the table.
I am using the following code: (I will get the path and the linked(renamed) name but not the File name)

Expand|Select|Wrap|Line Numbers
  1. Function fGetLinkedTables() As Collection
  2. 'Returns all linked tables except tblAlarmMasterBookedOut
  3. Dim collTables As New Collection
  4. Dim tdf As TableDef, db As Database
  5. Set db = CurrentDb
  6. db.TableDefs.Refresh
  7.  
  8. For Each tdf In db.TableDefs
  9.  With tdf
  10.   If Len(.Connect) > 0 Then
  11.      If Left$(.Connect, 4) = "ODBC" Then
  12.          collTables.Add Item:=.Name & ";" & .Connect, KEY:=.Name
  13.    'ODBC Reconnect handled separately
  14.      Else
  15.       If .Name <> "tblAlarmMasterBookedOut" Then
  16.               collTables.Add Item:=.Name & .Connect, Key:=.Name
  17.       End If
  18.     End If
  19.   End If
  20.  End With
  21. Next
  22. Set fGetLinkedTables = collTables
  23. Set collTables = Nothing
  24. Set tdf = Nothing
  25. Set db = Nothing
  26. End Function
Oct 4 '07 #1

✓ answered by twinnyfo

You should be able to find the Source Table using the TableDef.SourceTableName property.

Share this Question
Share on Google+
7 Replies


NeoPa
Expert Mod 15k+
P: 31,034
You're absolutely right, and I'm afraid I don't know the answer either. The .Connect string and even the Tools / Database Utilities / Linked Table Manager, only return the database name from whence the data comes. Luckily enough for me I very rarely rename my linked tables or require to reverse engineer where it comes from.
Sorry I couldn't be more help, but I have looked for this before without success.
Oct 4 '07 #2

P: 2
Yes, but when you move your mouse over it(table tab from left hand side), it shows the file name on hard disk as well as path.
I am guessing the file name on hard disk should be in there?
FYI: I have not renamed the file name on hard. i just renamed the linked table, from the table tab from left hand side.
Oct 4 '07 #3

NeoPa
Expert Mod 15k+
P: 31,034
Both the .Connect property and the Linked Table Manager will give you the file name on disk. It's only the table within the database that I can't find a link to.
Oct 4 '07 #4

twinnyfo
Expert Mod 2.5K+
P: 2,605
You should be able to find the Source Table using the TableDef.SourceTableName property.
2 Weeks Ago #5

NeoPa
Expert Mod 15k+
P: 31,034
I'd been here slightly less than a year when I last posted in this thread!! How did you even come across it?

Nowadays I know the answer to that one, but kudos to you for posting it :-)
1 Week Ago #6

twinnyfo
Expert Mod 2.5K+
P: 2,605
I was searching for a similar topic to see if there was an easier way to do things (which apparently there is not) and ran across this. See a thread that you did NOT have an answer too was too much to resist! I had to submit an answer!


:-)
1 Week Ago #7

NeoPa
Expert Mod 15k+
P: 31,034
Nice one.

Keep an eye on things for me. I'll visit when I can but everything's busy ATM.
1 Week Ago #8

Post your reply

Sign in to post your reply or Sign up for a free account.