Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compacting a DB via Code 1

Status
Not open for further replies.

mdr227

Programmer
Nov 17, 2000
114
US
What is the best way to compact and/or repair a db via code?  I am looking to do this both for the open DB (the one that is running the code) and for another one (for the data files).  Thanks.
 
You can try these two lines of code...<br><br>Repair:<br>&nbsp;&nbsp;DBEngine.RepairDatabase &quot;C:\your database name&quot;<br><br>Compact :<br>&nbsp;&nbsp;DBENgine.CompactDatabase olddb:=&quot;C:\????&quot;, newdb:=&quot;C:\????&quot;<br><br>Note:&nbsp;&nbsp;you can not repair or compact a databse that is these codes are being called from or an open database. Sorry, but it's a DAO limitation.<br><br>Hope this would help YOU... <p>Mohamed Aly<br><a href=mailto:samara_79@hotmail.com>samara_79@hotmail.com</a><br><a href= > </a><br>
 
To compact your front-end db while it is open, simply call the menu command from a command button.&nbsp;&nbsp;Use the code<br><br>&nbsp;&nbsp;&nbsp;&nbsp;SendKeys (&quot;%(TDC)&quot;)<br><br>I use this from a switchboard button with no problems.<br><br><br>
 
Thanks Lightning,

It is just what I have been looking for.

It worked for me, I do not know if it helped to origional poster, but it is just what the doctor ordered!!

Thanks

Randy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top