• Compact Backend in Code (XP)

    Author
    Topic
    #406564

    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.

    Viewing 3 reply threads
    Author
    Replies
    • #844095

      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:

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

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

    • #844096

      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:

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

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

    • #844131

      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: 374801 Re: Compact / Backup (XP)

      HTH

      • #844642

        Hans and Mark,

        Thanks for the help. Obviously I need to work on my searching techinque. 🙂

        You are both very helpful!

      • #844643

        Hans and Mark,

        Thanks for the help. Obviously I need to work on my searching techinque. 🙂

        You are both very helpful!

    • #844132

      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: 374801 Re: Compact / Backup (XP)

      HTH

    Viewing 3 reply threads
    Reply To: Compact Backend in Code (XP)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: