Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Oct 2001
    Location
    Western Massachusetts, USA
    Posts
    99
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Closing a second database (A2000)

    I have to Open and Close a database from another database so that the Compact On Close Option will execute. I have tried
    Dim MyDb as DAO.Database
    Set MyDb = OpenDatabase("PathToDb")
    MyDb.Close
    which doesn't do it.
    I have tried opening the file using the Shell Function and that opens it fine, but I can't close it. Anyone know how I would close the db after opening it using the Shell Function. Or anyother ideas.
    Thanks
    Paul

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

    Re: Closing a second database (A2000)

    Hi Paul,

    As always, there are several ways to get the job done. You're using DAO Objects to open the database. In this case, I would use Access Automation code:<pre>Sub OpenDatabase()
    Dim appAccess As Access.Application
    Set appAccess = CreateObject("Access.Application")
    'Replace database file and path with your own
    appAccess.OpenCurrentDatabase "D:My DocumentsYourDatabase.mdb", True
    'Insert your code
    appAccess.Quit
    Set appAccess = Nothing
    End Sub</pre>

    HTH <img src=/S/thumbup.gif border=0 alt=thumbup width=15 height=15>

  3. #3
    Star Lounger
    Join Date
    Oct 2001
    Location
    Western Massachusetts, USA
    Posts
    99
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Closing a second database (A2000)

    Thank you Mark. I was just coming back to say I got the answer and the answer was exactly what you posted. Thanks very much.
    Paul

Posting Permissions

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