MS Access DoCmd.Transferdatabase when source has a password

前端 未结 2 1927
傲寒
傲寒 2021-01-21 06:45

I need to import tables from various databases on a monthly basis. Once the tables are imported, the databases are archived and not looked at again.

I have the following

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-21 07:29

    Open the database with DAO, supplying the password, then you can import the tables.

    Public Sub ImportEncr()
    
        Const dbImport = "D:\DbEncr.accdb"
        Const sPassword = "foobar"
    
        Dim DB As DAO.Database
        Set DB = DBEngine.OpenDatabase(Name:=dbImport, Options:=False, ReadOnly:=False, Connect:=";PWD=" & sPassword)
    
        DoCmd.TransferDatabase acImport, "Microsoft Access", dbImport, acTable, "tblEncr", "tblEncr", False
    
        DB.Close
        Set DB = Nothing
    
    End Sub
    

    StoreLogin applies to linking tables from ODBC databases.

提交回复
热议问题