Title: link back-end password protected access database within same location
Tags: ms-access;vba
Question: I'm using the code below to link my bank-end database to the front-end. It works fine without having a password on the back-end DB. How do I use the same code with a password protected back-end file. NOTE: The following code is obtained from [Stackoverflow question][1]

``` [1]: https://stackoverflow.com/questions/3315306/how-can-a-relative-path-specify-a-linked-table-in-access-2007


    Private Sub Form_Load()
    Dim strOldConnect As String
    Dim strNewConnect As String
    Dim intSlashLoc As Integer
    Dim intEqualLoc As Integer

    Dim strConnect As String
    Dim strFile As String
    Dim strCurrentPath As String

    strCurrentPath = CurrentProject.path

    Dim tblDef As TableDef
    Dim tblPrp As Property

    For Each tblDef In CurrentDb.TableDefs
    Debug.Print tblDef.Name
    If tblDef.Connect &amp; "." <&gt; "." Then

        strOldConnect = tblDef.Connect
        intEqualLoc = InStr(1, strOldConnect, "=", vbTextCompare)
        strConnect = Left(strOldConnect, intEqualLoc)
        intSlashLoc = InStrRev(strOldConnect, "\", -1, vbTextCompare)
        strFile = Right(strOldConnect, Len(strOldConnect) - intSlashLoc)
        strNewConnect = strConnect &amp; strCurrentPath &amp; "\" &amp; strFile

        tblDef.Connect = strNewConnect
        tblDef.RefreshLink
    End If

    Next tblDef
    End Sub
```


Here is the accepted answer: I found a workaround myself and would like to share it, thank you.

```Public Function DBconnect()
Dim Password As String
Dim FileName As String
Dim CurrentConnection As String
Dim AccessConnect As String
Dim NewConnection As String
Dim CurrentPath As String
Dim CurrentLocationEnd As Integer

AccessConnect = "MS Access;PWD=password;DATABASE="
Password = "password"
CurrentPath = CurrentProject.Path

Dim tblDef As TableDef
Dim tblPrp As Property

For Each tblDef In CurrentDb.TableDefs
Debug.Print tblDef.Name
If tblDef.Connect &amp; "." <&gt; "." Then
CurrentConnection = tblDef.Connect
CurrentLocationEnd = InStrRev(CurrentConnection, "\", -1, vbTextCompare)
FileName = Right(CurrentConnection, Len(CurrentConnection) - CurrentLocationEnd)
NewConnection = AccessConnect &amp; CurrentPath &amp; "\" &amp; FileName
tblDef.Connect = NewConnection
tblDef.RefreshLink
End If
Next tblDef
End Function
```


Here is another answer: The whole connection string for Access ```Microsoft ACE OLEDB 12.0``` is:

```Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccessFile.accdb; Jet OLEDB:Database Password=MyDbPassword; 
```

See this link for reference https://www.connectionstrings.com/access/

In your case this would to the trick:

```tblDef.Connect = "PWD=" &amp; MyPassword &amp; ";DATABASE=" &amp; YourDatabasePath
```

Comment for this answer: Run-time error '3170': Could not find installable ISAM.

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 2, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2018:00:11/30/18', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<ms-access><vba>', 'Title': 'link back-end password protected access database within same location', 'ViewCount': 185, 'id': 53552530, 'user_AboutMe': None, 'user_AccountId': 14852978.0, 'user_DisplayName': 'Car Wings', 'user_Reputation': 1.0, 'user_Views': 5.0, 'user_id': 10726315.0}}