すべての接続文字列を出力するには:
Dim tdf As TableDef
Dim db As Database
Set db = CurrentDb
For Each tdf In CurrentDb.TableDefs
If tdf.Connect <> vbNullString Then
Debug.Print tdf.Name; " -- "; tdf.SourceTableName; " -- "; tdf.Connect
End If
Next
リンク テーブルを作成するには:
With CurrentDb
''If the table does not have a unique index, you will need to create one
''if you wish to update.
Set tdf = .CreateTableDef("LocalName")
tdf.Connect = "ODBC;DRIVER=SQL Server;SERVER=10.0.0.1;" _
& "UID=testdb;APP=Microsoft Office 2003;WSID=abc;TABLE=dbo.user"
tdf.SourceTableName = "TABLE_NAME"
.TableDefs.Append tdf
.TableDefs.Refresh
End With
リンクを変更するには:
Set db = CurrentDB
Set tdf = db.TableDefs("MyTable")
tdf.Connect = "ODBC;DRIVER=SQL Server;SERVER=10.0.0.1;" _
& "UID=testdb;APP=Microsoft Office 2003;WSID=abc;TABLE=dbo.user"
tdf.RefreshLink