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
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