Code to connect to encrypted / password-protected database
encryption, ms-access, ms-access-2007, vba
Solution
The method I used to do this is actually quite simple:
Set db = CurrentDb
Set dblink = DBEngine.OpenDatabase(strDbFile, False, False, ";PWD=" & strP)
For Each strTable In strLinkedTablesArray
DoCmd.TransferDatabase acLink, "Microsoft Access", dblink.name, acTable, _
strTable, strTable
Next
Problem
At start up, my front end front.accdr database links to a back end back.accde using: ``` DoCmd.TransferDatabase acLink, "Microsoft Access", "back.accde", acTable, "aTable", "aTable" ``` The back end really needs to be encrypted and so I need to use a password to connect to the encrypted DB. How would I do this?