[AccessD] Using TransferDatabase to link table from password protectd db

MartyConnelly martyconnelly at shaw.ca
Thu Apr 15 22:44:35 CDT 2004


There is no direct way to do this. I have heard of someone doing it this 
way via ODBC

DoCmd.TransferDatabase acLink, "ODBC Database", "ODBC;DSN=" & odbcname1 
& ";UID=" & user
& ";PWD=" & pass, acTable, "MyTable", "MyTable"

Or you can try it this way

 Public Function ImportDb(strPath As String) As Boolean
 Dim db As Database 'Database to import
 Dim td As TableDef 'Tabledefs in db
Dim strTDef As String 'Name of table to import

 'Open database which contains objects to import.
    Set db = DBEngine.Workspaces(0).OpenDatabase(strPath, False, False, 
"MS Access;PWD=<Your  password>")
  'Import tables from specified Access database.
    For Each td In db.TableDefs
    strTDef = td.Name
  If Left(strTDef, 4) <> "MSys" Then
   DoCmd.TransferDatabase acImport, "Microsoft Access", strPath, 
acTable, strTDef, strTDef, False
  End If
  Next

End Function

jeffrey.demulling at usbank.com wrote:

>I have the following code in a database.  Works fine if there is no
>password on the database.  However I need to add a password to the database
>the is being linked to.  How can I modify the code so that it accepts a
>password and does not prompt the user for one?
>
>
>Sub linkdatatable(mytable As String)
>
>    'Link in tables for query
>    If IsLinked(mytable) = False Then
>        DoCmd.TransferDatabase acLink, "Microsoft Access", GetDataFile,
>acTable, mytable, mytable, False
>    End If
>End Sub
>
>
>TIA
>
>
>
>  
>

-- 
Marty Connelly
Victoria, B.C.
Canada






More information about the AccessD mailing list