Purge Data

  • 13 years ago

    I am using a temporary table to hold data whilst I use code to manipulate the data.  As the code populates the table and then deletes the data in a loop the size of the database climbs.  Once the database gets over 1 GB it falls over. I can only reopen the database if I compact and repair it.

    Does anyone know any code to compact the database on the fly whilst it is still open?

  • 13 years ago

    Never tried this. Biggest access file I ever worked on was 350MB, and that was tooooooo big. Suggestion: move it somewhere else.

    However, as to your question:

    Note In Microsoft Access, you can compact a database while it is open, as long as the database has been opened exclusively.


    Dim db As New DAO.DBEngine()
    'CompactDatabase has two parameters, creates a copy of compact DB at the Destination path
    db.CompactDatabase(File_Path, compact_file)

    dunno what's going to happen if the File_Path and the compact_file is the same, whilst you're still "open" .. but you can always give it a shot (after backing up first)

    Good luck.


Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“There are only 3 numbers of interest to a computer scientist: 1, 0 and infinity”