Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Sep 2006
    Posts
    166
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Transfer database (Access 2000)

    I have problems with the command TransferDatabase.When i open a database with a password, it is OK, but when i add on the command TransferDatabasesekd, i am asked for the password, even though the password exists in the command :
    Public Function ExportTables()
    Dim wsp As DAO.Workspace
    Dim StrPassword As String
    StrPassword = "secret"
    Set wsp = DAO.DBEngine.Workspaces(0)
    Dim dbs As DAO.Database
    Set dbs = wsp.OpenDatabase("C:BEstoreBE.mdb", False, False, ";PWD=" & StrPassword)
    DoCmd.TransferDatabase acExport, "Microsoft Access", ("C:BEstoreBE.mdb"), acTable, "Customers", "Customers"
    dbs.Close
    End Function

    If i remove the command Transferdatabase, then i get no error and i am not asked for the password.What is wrong with my function ?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Transfer database (Access 2000)

    The DoCmd.TransferDatabase instruction has nothing to do with the OpenDatabase instruction that precedes it. The instructions serve completely different purposes. You cannot supply a database password to TransferDatabase.

    Instead of exporting to the password-protected database, you can import into it.

  3. #3
    2 Star Lounger
    Join Date
    Sep 2006
    Posts
    166
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Transfer database (Access 2000)

    Thank you Hans. Just to bring my question to the end is it absolutely impossible to send a table to a password protected database ? For example with copy object or some other method ?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Transfer database (Access 2000)

    You could try using SendKeys. Let's say that the password is "Secret".
    <code>
    SendKeys "Secret~"
    DoComd.TransferDatabase ...
    </code>
    The <code>~</code> at the end of the SendKeys instruction corresponds to the Enter key.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •