• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 436
  • Last Modified:

Changing linked table location (that protected with a password) programatically on acccess 2013


how can i with vba relink a table to database that closed with password. for example i have this code  
 For Each td In TDS
        If td.Connect = ";DATABASE=" & OldPathName Then
            td.Connect = ";DATABASE=" & NewPathName, passowrd:mypassword'
            td.RefreshLink 'Refresh the link

Open in new window

  • 2
1 Solution
Try this

Public Function FixTableLink()
Dim db As Database
Dim strPath As String
Dim strConnect As String
strPath = "NewPathName"

strConnect = ";DATABASE=" & strPath & "; password:mypassword"
Set db = CurrentDb
For Each tbl In db.TableDefs
    If Nz(DLookup("Type", "MSysObjects", "Name = '" & tbl.name & "'"), 0) = 6 And tbl.Connect <> strConnect Then
        tbl.Connect = strConnect
    End If
Next tbl
End Function
sorry connection string should be

strConnect = ";DATABASE=" & strPath & "; PWD=mypassword"
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now