MS Access DoCmd.Transferdatabase when source has a password

前端 未结 2 1928
傲寒
傲寒 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:16

    You can use SQL and build a SQL statement and .RunSQL that I believe.

    An example SQL would be

    SELECT * into tblIMPORT FROM xyz IN '' '; database=C:\Workspace\Database1.accdb;PWD=test';

    Hope this helps.

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题