Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Nov 2001
    Thanked 0 Times in 0 Posts

    transfer a database and protect it (Access 2000)

    Transfer to a database and then protect it

    I use the following function suggested to me as follows

    Public Sub CreateDBWithPwd(dbFile As String, strPassWord As String)
    Dim db As DAO.Database
    ' create database which can be opened only with password passed as parameter
    Set db = DBEngine.Workspaces(0).CreateDatabase(dbFile, dbLangGeneral & ";pwd=" & strPassWord)
    Set db = Nothing
    End Sub

    and then on the OnClick event i use the folllowing:

    Private Sub Command0_Click()
    Call CreateDBWithPwd "c:beprotectedDb.mdb", "secret"
    End Sub

    It works fine. My problem is, that after creating the database ProtectedDB.mdb, i cannot ship the tables to the protected database
    using the followin code:
    DoCmd.TransferDatabase acExport, "Microsoft Access", bappath, acTable, "table1", "table1"
    Because i am asked about the password,and the code does not export the tables.

    Can somebody help me? Just to tell you in plain words what i want.I want to create a database, ship 4 tables to this database and then protect it with a password.But i cannot find the right way to do it.

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Sint Niklaas, Belgium
    Thanked 0 Times in 0 Posts

    Re: transfer a database and protect it (Access 2000)

    Instead of the transferdatabae command, you could open the protecteddb.mdb and use the copyobject command.
    Here a sample:
    <pre>Sub CopyTable()
    Dim db As DAO.Database
    Dim ws As DAO.Workspace
    Dim rst As DAO.Recordset
    Set ws = DBEngine.Workspaces(0)
    Set db = ws.OpenDatabase("Crotecteddb.mdb", False, False, "MS Access;PWD=secret")
    DoCmd.CopyObject db.Name, "table1", acTable, "table1"
    End Sub</pre>

    This sample was is a modified version of the sample in the Knowledge Base article Q209953

Posting Permissions

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