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
Solved

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

Posted on 2014-03-01
2
421 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
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

User Beware!  This is a rather permanent solution to removing your email from an exchange server.  The only way to truly go back is to have your exchange administrator restore your mailbox from backups.  This is usually the option of last resort.  A…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
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…

789 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