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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compact and Repair Database Using VBA 3

Status
Not open for further replies.

JesseH

MIS
Aug 9, 2001
63
0
0
US
I would like to 'compact and repair' the database using VBA code so that I would not have to rely on the user to do this. Can anybody provide the code necessary to do this.

Thanks in Advance.

JesseH
 
Depending of the version of access you may choose the option of compacting the database on close.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks PHV, we are using Access 2000. The database is too unwieldy to compact on exit. I was trying to compact weekly.
 
you could setup a scheduled task to run and use the /compact switch to compact the database.

"C:\Program Files\Microsoft Office\Office\MSACCESS.EXE" "C:\Documents and Settings\DC57873\Desktop\Database.mdb" /compact
 
Since office (access) 2000 it is possible to use hidden interface IAccessible to compact DB on demand, by code:
Code:
Sub CompactThisDB()
Dim conCompact As Office.CommandBarControl
Set conCompact = CommandBars.FindControl(Id:=2071)
conCompact.accDoDefaultAction
End Sub

combo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top