Compacting database not working

bri822

Registered User.
Local time
Today, 11:27
Joined
May 23, 2002
Messages
31
I set my database to compact on close orginally, but it was taking a lot time since it was being run off a network and users start to complain. So I was looking at trying to compact the database by checking the file size when a user clicked exit. I have the checking down, just need to figure out how to compact it. I have tried the:
SendKeys "{f10}"
SendKeys "TDC"

and

DoCmd.RunCommand acCmdCompactDatabase

and

DBEngine.CompactDatabase Application.CurrentProject.Path & "/" & strName, Application.CurrentProject.Path & "/temp.mdb"
Kill Application.CurrentProject.Path & "/" & strName
Name Application.CurrentProject.Path & "/temp.mdb" As Application.CurrentProject.Path & "/" & strName

With sendkeys, it ended up sending the keys after the database closed, even though I have the code before it exits the application. The RunCommand did not work b/c you can't compact the database inside a macro or code (some error that came up). And compacting by copying did not work b/c I had the database opened when I was copying.

If anyone else has any other ideas, I would really appreciate it. I would also like to try to not use another program to compact the database, I know they are out there, but I would perfer to do it from code inside my program.

Brian
 
Why not...?

I studied the same problem here where I work.
I came to the conclusion that I would create an application that would compact all DB's I need compacted and repaired... I created a batch file, so the DB opened automatically on it's own on the weekend's. In an autoexec macro, fired the jobs to compact and repair the DB's, then executed the shut down command.
This way I had a back-up from Friday night, and also Sunday night if ever I encoutered any problems from my auto methods. This works for me, hope it gives you some ideas...

Regards,
 

Users who are viewing this thread

Back
Top Bottom