1.VBAの参照設定で右記をチェックする『Micrsoft ADO Ext *.* for DDL and Security』
2.テーブルのリンク先を変更するVBAを以下に説明します。
作成するVBA
・
・
Dim AdoCat As New ADOX.Catalog
Dim AdoTbl As New ADOX.Table
Dim fPath As String
・
・
fPath = "C:\Documents and Settings\All Users\data.mdb" '変更するmdbパス
AdoCat.ActiveConnection = CurrentProject.Connection
For Each AdoTbl In AdoCat.Tables
If (AdoTbl.Type = "LINK") Then 'リンクされたテーブル?
AdoTbl.Properties("Jet OLEDB:Link Datasource") = fPath 'mdbパスを変更する
End If
Next
・
2.テーブルのリンク先を変更するVBAを以下に説明します。
作成するVBA
・
・
Dim AdoCat As New ADOX.Catalog
Dim AdoTbl As New ADOX.Table
Dim fPath As String
・
・
fPath = "C:\Documents and Settings\All Users\data.mdb" '変更するmdbパス
AdoCat.ActiveConnection = CurrentProject.Connection
For Each AdoTbl In AdoCat.Tables
If (AdoTbl.Type = "LINK") Then 'リンクされたテーブル?
AdoTbl.Properties("Jet OLEDB:Link Datasource") = fPath 'mdbパスを変更する
End If
Next
・
※コメント投稿者のブログIDはブログ作成者のみに通知されます