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

Compact a Ms Access db from VB

Status
Not open for further replies.

thoms

Programmer
May 27, 2002
4
BE
Hi,

I am trying to compact a database from VB, in a way that in the end, this VB project will be concverted to an exe file, from where users select the Ms Access db to compact, and click on a button to do it.

I would need some ideas about the code to use to compact the database. I would like to keep the same name of the database.

Thanks,

Thoms
 
Hi,

Make a reference to Jet and replication object, and:
--------------------------------------------------------------
Dim JRO As JRO.JetEngine, NewStrCon As String, OldSize As String
Set JRO = New JRO.JetEngine
JRO.CompactDatabase StrCon, NewStrCon ' where StrCon is a connection string to the database and NewStrCOn is a connectionstring to the new compacted database
Kill dbName 'delete old db
Name App.Path + "\tmp.mdb" As dbName 'rename compacted as the old
--------------------------------------------------------------


Sunaj
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top