I have created an application in VB using Access. I need to figure out how to use the Compact and Repair feature found in Acces either with in my application or as a stand alone feature distributed with my application. Any and all help is appreciated.
I think u use this for Compacting DB
DBEngine.CompactDatabase olddb, newdb, locale, options, password
and
DBEngine.RepairDatabase dbname to repair Db....
but be sure that u have closed the database before u start doing a repair or compact...
Take a look at the VB object browser (F2) for Access, that should get you going with the VB syntax. I think it'll be something like objAccess.DoCmd(acCmdCompactDatabase). Another thing you should be aware of is that all users must be logged out of the db including your VB app before it'll run. I think the simple solution to that would be to close any recordset connections you have open. Just wanted to make sure you didn't get bit by that later...
HTH!
~Mike
Any man willing to sacrifice liberty for security deserves neither liberty nor security.
Here ya go:
------------
Dim XS As Access.Application
XS.OpenCurrentDatabase "c:\test.mdb"
XS.DoCmd.RunCommand (acCmdCompactDatabase)
Set XS = Nothing
------------
Good luck!
~Mike
Any man willing to sacrifice liberty for security deserves neither liberty nor security.
When using
DBEngine.CompactDataBase "source", "Destination"
I receive a message that the DB already exists. How can I compact the database with out creating a new DB or changing the name.
Is it possible to delete the original DB and then change the DB name of the ompacted DB back to the original file name?
That's exactly what you need to do. Best to make a copy before you compact unless it gets screwed, and then of course you need code to copy the backup back. Peter Meachem
peter@accuflight.com
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.