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 database

Status
Not open for further replies.

damrus

Technical User
Jun 22, 2008
24
0
0
PL
Hoping that someone help me...

I would like to compact database in the middle of running a code in VBA.
Is it possible to compact dtb using VBA under the same Access database?


For example:
sub t()

For i = 1 To 999
DoCmd.RunSQL "blabla"
Next

' ! here I would like to put a code to compact the database

For i = 1000 To 9999
DoCmd.RunSQL "blabla"
Next
End sub
 
To compact the database you have open, no you would not be able to resume. You could store a value or procedures in a table snd conditionally run them when your database re-opens. You could however compact a backend, if there are no connections opened (no locking file).

Anyway the things to look at to compact are... The first allows you to specify a password and the second does not. I would go with the second if there is no password.

DBengine.Compactdatase
Application.CompactRepair
 
You should also know that many believe Compacting to be a cause of corruption, and hence a Backup Copy of the Database should be always be made before Compacting.

The Missinglinq

Richmond, Virginia

The Devil's in the Details!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top