Does someone know the VB code to Open an access database, exclusively, to compact and repair it?
Opening it has been easy and compacting hasn't been tough but I can't get it repair a damaged database with using Access or microsofts jetcomp program.
Help....
Comments
: Does someone know the VB code to Open an access database, exclusively, to compact and repair it?
:
: Opening it has been easy and compacting hasn't been tough but I can't get it repair a damaged database with using Access or microsofts jetcomp program.
:
:
: Help....
:
You can use CompactDatabase and RepairDatabase methods of the DBEngine object.
eg:
DBEngine.CompactDatabase strInput strOutput
This compacts the database. strInput is the database file to be actioned on and strOutput is the resultant compacted database file name.
DBEngine.RepairDatabase strInput
This repairs a database. A trapable error 3049 can be checked for. This error indicates the database is possibly corrupt and therefore RepairDatabase method can be implemented.
To open a database exclusively:
Set db = dbEngine.Workspaces(0).OpenDatabase (strDBase,True)
Hope this helps.
John