Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Feb 2002
    Thanked 0 Times in 0 Posts

    errors in opening a remote database (Access 2000)

    I have the following task:
    I must open a remote database called Order, and to open a form in this remote database called frmGaruda.
    The database Order is protected with the password punch.
    In order to achieve that, i have copied some solutions and proposals.However in copying these soltions
    i must have done some grave mistakes in my function becasue it does not always work.In some computers it works and in some not.
    What i want to ask is the folllowing.I would like that some professional or developer has a look at my code and tells
    me where i am wrong.I will be so gratefil for that.There MUST be some serious mistake in my function.It is the following:

    Public Function FncGaruda()

    Dim StrPassword As String
    StrPassword = "punch"
    Dim db As DAO.Database
    Set db = DBEngine.Workspaces(0).OpenDatabase("C:beOrder.mdb , dbDriverComplete, False, ; PWD=" & StrPassword)
    DoCmd.TransferDatabase acExport, "Microsoft Access", "C:beOrder.mdb", acModule, "FOrderInformationOffice", "FOrderInformation"
    Dim strDbName As String
    strDbName = ("C:beOrder.mdb")
    Set acc = New Access.Application
    acc.Visible = True
    Set db = acc.DBEngine.OpenDatabase(strDbName, False, False, ";PWD=punch")
    acc.OpenCurrentDatabase strDbName
    acc.DoCmd.OpenForm "frmGaruda", acNormal
    Set db = Nothing
    End Function

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 31 Times in 31 Posts

    Re: errors in opening a remote database (Access 2000)

    Your code seems to consist of different ideas thrown together.

    You need to distinguish OpenDatabase and OpenCurrentDatabase.

    OpenDatabase opens a database as a DAO object, but not in the interface (in the database window). You can use it to manipulate table and query objects, not to open forms, reports etc. You can have multiple databases open at the same time this way.

    OpenCurrentDatabase opens a database in the interface. An instance of Access can have only one database open in the database window.

    As far as I can tell, you don't need the db object at all.

    Here is a suggestion for a modified function. Since I don't know what you want to accomplish by opening a form and closing the database immediately after that, it may not do exactly what you want.

    Public Function fncGaruda()
    Dim strDbName As String
    Dim appAccess As New Access.Application
    strDbName = ("C:beOrder.mdb")
    DoCmd.TransferDatabase acExport, "Microsoft Access", strDbName, acModule, _
    "FOrderInformationOffice", "FOrderInformation"
    With appAccess
    .Visible = True
    ' OpenCurrentDatabase has no password argument; use SendKeys
    SendKeys "punch{ENTER}"
    .OpenCurrentDatabase strDbName
    .DoCmd.OpenForm "frmGaruda", acNormal
    .Quit acQuitSaveNone
    End With
    Set appAcc = Nothing
    End Function

  3. #3
    New Lounger
    Join Date
    Jul 2002
    Thanked 0 Times in 0 Posts

    Re: errors in opening a remote database (Access 2000)

    i want to send to you my special regards and gratitude for the nice help you have given to me.IMy problem seems a lot clearer to me now

Posting Permissions

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