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

    remote db with password (Access 2000)

    I have a function that deletes a table in a remote database that works perfect as long as the remote database has no password.
    Ususally i open the dtabase having a password with the following code:
    Dim StrPassword As String
    StrPassword = "secret"
    Dim db As DAO.Database
    Set db = DBEngine.Workspaces(0).OpenDatabase(BEpath, dbDriverComplete, False, "; PWD=" & StrPassword)

    However i canot used it with my new function to delete the table.Here is the function i use:

    Public Function FncRemoteProducts()
    Dim StrPassword As String
    StrPassword = "secret"
    Dim db As DAO.Database
    Set db = DBEngine.Workspaces(0).OpenDatabase(BEpath, dbDriverComplete, False, "; PWD=" & StrPassword)
    Call KillObject(BEpath, 0, "products")
    DoCmd.TransferDatabase acExport, "Microsoft Access", BEpath, acTable, "products", "products"
    End Function

    In the above function i am still asked for a password.I cannot solve tis problem.

    In the above code i refer to the code KillObject as follows:

    Public Sub KillObject(strDBName As String, acObjectType As Long, strObjectName As String)
    Dim adb As Object
    Set adb = CreateObject("Access.Application")
    adb.OpenCurrentDatabase (strDBName)
    adb.DoCmd.DeleteObject acObjectType, strObjectName
    adb.CloseCurrentDatabase
    Set adb = Nothing
    End Sub


    I must emphasize that previously my function killobject worked very good, i simply do not know ho to apply it with the strPassword.
    I will be extremely grateful for any help

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

    Re: remote db with password (Access 2000)

    In the procedure KillObject, you don't use the database you opened in the function FncRemoteProducts. Instead, you start a new instance of Access with CreateObject, and open the database as current database in that instance. You can't specify a password in OpenCurrentDatabase (at least in Access 97).

    You might try passing the password by issuing

    SendKeys "password"

    immediately before the line with OpenCurrentDatabase. Haven't actually checked that.

    Or you can create a procedure KillTable and pass the database object instead of the database name to it along with the table name.

    Public Sub KillTable(db As DAO.Database, strTableName As String)
    db.TableDefs.Delete strTableName
    End Sub

    Call it as follows:

    Call KillTable(db, "Products")

Posting Permissions

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