Solved

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

Posted on 2014-03-01
2
422 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 16

Expert Comment

by:Sheils
ID: 39898150
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
ID: 39898156
sorry connection string should be

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

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

740 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