Results 1 to 4 of 4
  1. #1
    4 Star Lounger
    Join Date
    Jan 2003
    Location
    Central Florida, USA
    Posts
    505
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Compact Backend in Code (XP)

    I apologize in advance if this has been asked and answered already, but I couldn't find it in a search. Is it possible to compact a database backend from the front end that uses the tables? I have not had any luck finding the correct syntax for the "DoCmd.RunCommand acCmdCompactDatabase" which I assume is the right thing. If this is the correct method, how do you tell it which database? How do you feed it the path?

    Thanks in advance for your ideas.

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

    Re: Compact Backend in Code (XP)

    You must make sure that the front end (all front ends, for that matter) doesn't have a table open in the backend. One way to test this is to check that there is no .ldb file belonging to the backend (or, if it exists, that it can be deleted.)
    If all is clear, you can issue a Shell instruction to compact the database:

    <code>Shell """C:Program FilesMicrosoft OfficeOffice10MSAccess.exe"" ""serversharefolderMyBackend.mdb"" /compact"</code>

    or use DAO, as described in MSKB article ACC2000: How to Compact Databases At a Scheduled Time.

  3. #3
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Compact Backend in Code (XP)

    A month or so ago I posted some sample code that demonstrates how to compact & backup back end database from a front end, using the DAO DBEngine CompactDatabase method, along with VBA commands to copy & backup files, etc. If interested see this post:

    <!post=Post: 374801 Re: Compact / Backup (XP),374801>Post: 374801 Re: Compact / Backup (XP)<!/post>

    HTH

  4. #4
    4 Star Lounger
    Join Date
    Jan 2003
    Location
    Central Florida, USA
    Posts
    505
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Re: Compact Backend in Code (XP)

    Hans and Mark,

    Thanks for the help. Obviously I need to work on my searching techinque. :-)

    You are both very helpful!

Posting Permissions

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