我想从Excel更改Access的链接表管理器

时间:2017-08-11 17:23:49

标签: excel-vba ms-access vba excel

嗨,我想要我的宏:

更改我的request_MANDescriptifAdr.mdb的链接表管理器中的链接,以获取来自MANDescriptifAdr.mdb的表SIGAdPoAAAAMMJJRXX_ORI

Private Sub CommandButton6_Click()

    Dim folderPath As String

    folderPath = Application.ActiveWorkbook.Path

    Dim db As Object


    Set db = CreateObject("ADODB.Connection")
    OpenDatabase = folderPath & "Request_MANDescriptifAdr.mdb"



    db.OpenDatabase = folderPath & "Request_MANDescriptifAdr.mdb"
    db.TableDefs("SIGAdPoAAAAMMJJRXX_ORI").Connect = "MS Access;DATABASE=" & folderPath & "MANDescriptifAdr.mdb"
    db.TableDefs("SIGAdPoAAAAMMJJRXX_ORI").RefreshLink

End Sub

1 个答案:

答案 0 :(得分:1)

我以为我已经在你上一期的评论部分回答了这个问题,但是没关系:

Private Sub CommandButton6_Click()

  Dim folderPath As String

  folderPath = Application.ActiveWorkbook.Path

  Set Db = CreateObject("DAO.DBENGINE.120").OpenDatabase(folderPath & "Request_MANDescriptifAdr.mdb")

  db.TableDefs("SIGAdPoAAAAMMJJRXX_ORI").Connect = "MS Access;DATABASE=" & folderPath & "MANDescriptifAdr.mdb"

  db.TableDefs("SIGAdPoAAAAMMJJRXX_ORI").RefreshLink
End Sub