问题
I have five tables in my application in which two are local table and three are linked table, I'm not sure about my code how to get name of table. I want a code for provide me name of both type of table name separately using for loop.
Table Name
LocalTable1
LocalTable2
LinkTable1
LinkTable2
LinkTable3
Code
Dim td As TableDef
Dim stConnect As String
For Each td In CurrentDb.TableDefs
Debug.Print td.Name
Next
回答1:
You can use the source table name:
Dim db As Database
Dim tdf As TableDef
Set db = CurrentDb
For Each tdf In db.TableDefs
If Left(tdf.Name, 4) <> "MSys" Then
Debug.Print tdf.Name & IIf(tdf.SourceTableName <> "", " source table: " _
& tdf.SourceTableName, "")
End If
Next
来源:https://stackoverflow.com/questions/25579591/get-the-name-of-local-table-and-linked-table-in-vba