Solved

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

Posted on 2014-03-01
2
414 Views
Last Modified: 2014-03-02
hi

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

0
Comment
Question by:bill201
  • 2
2 Comments
 
LVL 16

Expert Comment

by:Sheils
Comment Utility
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
        tbl.RefreshLink
         
    End If
 
Next tbl
 
End Function
0
 
LVL 16

Accepted Solution

by:
Sheils earned 500 total points
Comment Utility
sorry connection string should be

strConnect = ";DATABASE=" & strPath & "; PWD=mypassword"
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

The System Center Operations Manager 2012, known as SCOM, is a part of the Microsoft system center product that provides the user with infrastructure monitoring and application performance monitoring. SCOM monitors:   Windows or UNIX/LinuxNetwo…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now