Refreshing link to encrypted acess 2007 database using adox

M

Max

I have two access 2007 accdbs (front end and back). I need to refresh the
links and have the backend encrypted using a password. There is no other
security on it. I get an invlaid password error when I use the code below. I
got this from an MS article and cannot seem to get it to work. If I remove
the password it works like a champ. Any help appreciated.

Sub RefreshLinks()

Dim cat As ADOX.Catalog
Dim tbl As ADOX.Table
Dim strNewPath As String
Dim strPassword As String


strNewPath = fGetMDBName("Please select a new datasource")
strPassword = "mossy"
Set cat = New ADOX.Catalog

' Open the catalog.
cat.ActiveConnection = CurrentProject.Connection

Set tbl = New ADOX.Table

For Each tbl In cat.Tables
' Verify that the table is a linked table.
If tbl.Type = "LINK" Then
tbl.Properties("Jet OLEDB:Link Provider String") = "MS
Access;PWD=mossy;"
tbl.Properties("Jet OLEDB:Link Datasource") = strNewPath
' To refresh a linked table with a database password set the Link Provider
String
'tbl.Properties("Jet OLEDB:Link Provider String") = "MS
Access;PWD=mossy;"
'tbl.Properties("Jet OLEDB:Database Password") = "mossy"
'tbl.Properties("Jet OLEDB:Link Provider String") = "MS
Access;PWD=" & strPassword & "'"
End If
Next

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top