Calling 'Compact and Repair' in code

Dugantrain

I Love Pants
Local time
Today, 13:25
Joined
Mar 28, 2002
Messages
221
I have a Switchboard which, when a particular button is clicked, Deletes all records out of a table, Appends several thousand records to that table, updates all of those records, calls a Select query to show filtered results from that table in a Report, and then Deletes all of the items out of that table again. The problem is that even after all of the records have been deleted, the db is still bloated to over twice its normal size. Is there a way to call Compact and Repair in the On-Click event of this command button? (I don't want to set it to Compact and Repair every time it closes as our network is slow and people pop in and out of the database all the time. This command button, however, will only be used about once a week or so).

*I now see in the Visual Basic Help Files that there is a CompactDatabase method, but for some reason, it won't let me open this file. If anyone has a snippet of code on how to use this method, it'd be much appreciated.

*Well, now, wait. Looking through posts, I see that it may be impossible to Compact and Repair while the db is open. So if anyone can give me a definitive answer, either yes or no, if this can be done, then please do so.
 
Last edited:
You cannot compact a database while others are still in the database. Only you can be in the database in order to compact it. You can use code. Search the forum, there have been many examples given in the past on how to use code to accomplish this.
 
There is sample code around somewhere to kick all users out and perform the said task, I'll try a search it out
 

Users who are viewing this thread

Back
Top Bottom