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

    Compact on close (Access 97 SR2)

    I'm wanting to compact my db on close. I've stored all the code in a second database and when I open it manually it works perfectly so all the hard work is done - but I have one question - how do I close my current database and open the other one to compact it?

    I know this should be easy but I just can't seem to get it.

    Thanks in advance!

  2. #2
    New Lounger
    Join Date
    Nov 2001
    Location
    Carlisle, PA
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Compact on close (Access 97 SR2)

    One way would be to use the Shell command to open the other database.

    Sub OpenCompactDatabase()
    Dim stemp As String

    stemp = stemp & Chr(34) 'Double Quote
    stemp = stemp & "C:Program FilesMicrosoft OfficeOfficeMSACCESS.EXE" 'Location of MSAccess
    stemp = stemp & Chr(34) 'Double Quote
    stemp = stemp & " " 'Space
    stemp = stemp & Chr(34) 'Double Quote
    stemp = stemp & "C:YourDatabase.mdb" 'Location of your Database
    stemp = stemp & Chr(34) 'Double Quote

    Shell (stemp)
    End Sub

    Because the Shell command runs other programs asynchronously. Your Database should finish closing after it executes the shell command. You should build a delay into your compact database just to make sure that it's closed before you start your compact routine.

    Hope this helps

    Jerid

Posting Permissions

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