Max Bridge
Max Bridge

Reputation: 331

I want to change the Linked table manager of Access from Excel

Hi I want my macro to :

Change the link in my linked table manager of my request_MANDescriptifAdr.mdb for the table SIGAdPoAAAAMMJJRXX_ORI from MANDescriptifAdr.mdb

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

Upvotes: 0

Views: 268

Answers (1)

Erik A
Erik A

Reputation: 32682

I thought I already answered this in the comment section of your last question, but nevermind:

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

Upvotes: 1

Related Questions