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

backup and compress Access Db from VB

Status
Not open for further replies.

ISDleftovers

Technical User
Dec 18, 2000
6
0
0
AU
I have not been able to find the functions to call an Access Backup or an Access Compress from VB, if anyone knows what functions to call to complete these simple tasks, I wouls greatly appreciate your help.
as well as performing a backup, I hope to be able to restore from backup so help with this would be great too.
 
make first a copy of your database...

Compact An Access Database From VB

This code will show you how to compact an access database (As you can do from Microsoft Access Application) from Visual Basic using code.

Preparations
Add reference to DAO:
from the menu choose Project-> References, mark the Microsoft DAO 3.6 (or 3.51) Object Library check box, and press OK.

Add 1 Command Button to your form.
Press the button to compact the database.

If you got "Unrecognized Database format" error message:

If you using database that made in Access 2000 and you don't have Microsoft DAO 3.6 Object Library reference, click on browse, and select the file C:\Program Files\Common Files\Microsoft Shared\Dao\dao360.dll (If you have Access 2000 installed in your computer you have this file.)
This will add Microsoft DAO 3.6 Object Library reference to your project. Now mark it and press OK.

Form Code
Private Sub Command1_Click()
' this line will compact the "c:\myDir\db1.mdb" database to "c:\myDir\db2.mdb".
' after this line had been called you will have the original
' uncompacted database in "c:\myDir\db1.mdb"
' and the new compacted database in "c:\myDir\db2.mdb".
DBEngine.CompactDatabase "c:\myDir\db1.mdb", "c:\myDir\db2.mdb"
End Sub

Eric De Decker
vbg.be@vbgroup.nl

Licence And Copy Protection AxtiveX.

Download Demo version on my Site:
Promotions before 02/28/2001 (free source codebook),visite my site
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top