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

Compacting Access Database From a Form with DAO's

Status
Not open for further replies.

wusinik

Programmer
Jul 12, 2001
20
US
I am trying to compact my local databse every time data is written there(initiated by pressing a command button)...the problem is that I get a message saying that the database is already opened for exclusive use by myself. There are DAO's on the form. Can I execute the compact command even if the form has DAO's?

Thanks
 
Hi,

You've probably have the database open.
You can't compact the database when it is open. Close it and then compact it.
Then the datebase is closed you can compact it by setting a reference to 'Microsoft Jet and Replication Objects' and

JRO.CompactDatabase StrCon, NewStrCon

Where StrCon conbtains your connection string and NewStrCon is your connection string with a new database name. If you like you can use 'kill' to delete the old database and 'name as' to rename the new to the original file name.


Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top