Results 1 to 8 of 8
  1. #1
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Opening another database (Access2000)

    I have a situation in where there are 2 databases, let's just call them db1 and db2. While in db1, I need to open db2 in another instance of Access. This part is no problem.

    However, what I want to be able to do is determine if db2 is already opened, and then use that instance of Access rather than creating a new one. Anyone know how to do this?
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  2. #2
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Opening another database (Access2000)

    Can't you just grab the other instance of Access and use the CurrentDB() function?
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  3. #3
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Opening another database (Access2000)

    >>Can't you just grab the other instance of Access and use the CurrentDB() function? <<

    That's part of my question. How do I do that?
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  4. #4
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Opening another database (Access2000)

    Well, now you're asking hard questions seeing that I don't think that I've ever written an Acess program! <img src=/S/drop.gif border=0 alt=drop width=23 height=23> Where's is Charlotte when I need her? Well, let me try to write the code. I'll be back later! --Sam
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

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

    Re: Opening another database (Access2000)

    Mark, I'm not clear on what you're trying to do, but you can attempt to open the other db exclusively, which will fail if it's already open. Does that help? Here's some sample code:

    <pre>Public Function CanOpenDBExclusive(strDBPath As String) As Boolean
    'Created by Charlotte Foust 7/16/99
    On Error Resume Next
    Dim dbs As DAO.Database
    Dim blnCanOpen As Boolean
    Const DB_OPEN_EXCLUSIVE = True

    Set dbs = DBEngine.Workspaces(0).OpenDatabase(strDBPath, DB_OPEN_EXCLUSIVE)
    If Err = 0 Then
    blnCanOpen = True
    End If

    CanOpenDBExclusive_exit:
    dbs.Close
    Set dbs = Nothing
    CanOpenDBExclusive = blnCanOpen
    End Function</pre>

    Charlotte

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

    Re: Opening another database (Access2000)

    You could use GetObject:

    Dim obj As Object
    On Error Resume Next
    Set obj = GetObject("C:Accessdb2.mdb")
    If obj Is Nothing Then
    ' Database is not open, so put code to open it here
    Else
    ' Database is already open, use obj to refer to it
    ' The instance of Access running it is obj.Parent
    End If

  7. #7
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Opening another database (Access2000)

    Thanks Hans, I think this is what I need.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  8. #8
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Opening another database (Access2000)

    Hans,

    Thanks again. Works great!
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

Posting Permissions

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