Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Posts
    254
    Thanks
    0
    Thanked 0 Times in 0 Posts

    open a database from another database and then ope

    Open a database from another database and then open a form

    I want to build a function that opens a database called Lib and then open
    a form in this databse called F1.I want to do it while being in another database
    however i cannot do it and i do not know is it possible at all.
    Any help ?
    My would be functionn that doesnt work is the following

    Public Function OpenF1()
    Dim objConn As New ADODB.Connection
    objConn.Open "Provider= Microsoft.Jet.OLEDB.4.0;Data Source = c:BEStorelib.mdb"
    DoCmd.OpenForm "F1"
    End Function

  2. #2
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: open a database from another database and then ope

    I'm sure there are better ways to do this, but here's the code I've used successfully in the past:

    Dim appAccess as Access.Application
    Set appAccess = CreateObject("Access.Application.8")
    appAccess.OpenCurrentDatabase "C:MyPathMyDatabase.mdb"
    appAccess.DoCmd.OpenForm "MyFormName", acNormal
    appAccess.Visible = True
    appAccess.UserControl = True
    appAccess.DoCmd.RunCommand acCmdAppMaximize 'This maximizes the window

    Note: This was for Access 97. It should work in Access 2000 with no problems, except you'll need to change the version number to "9" for CreateObject("Access.Application.8").

    HTH[img]/w3timages/icons/thinks.gif[/img]
    -MarkJ-

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: open a database from another database and then ope

    You can do this transparently if your Lib database is an add-in. When you install a database as an add-in, its forms become available to you from the current database. However, add-ins are not just ordinary databases. They must contain a table called USysRegInfo, and that has to be just what Access and Windows expect, or it won't work. You can find information on building add-ins on Helen Feddema's site: http://www.helenfeddema.com/. Just be aware that Microsoft changed the structure of USysRegInfo between Access 97 and 2000, so 97 add-ins don't work in 2000 without modification.
    Charlotte

Posting Permissions

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