Hi Ali,
If you mean compact and repair the current open database which the code
runs in, it can't be done except the check box Jim mentioned. However, we
can compact and repair other database file, if you want to repair other
database instead of the current open database, you can refer to
RepairDatabase Method Example in Access help file, cited below for your
convenience:
RepairDatabase Method Example
This example attempts to repair the database named Northwind.mdb. You
cannot run this procedure from a module within Northwind.mdb.
Sub RepairDatabaseX()
Dim errLoop As Error
If MsgBox("Repair the Northwind database?", _
vbYesNo) = vbYes Then
On Error GoTo Err_Repair
DBEngine.RepairDatabase "Northwind.mdb"
On Error GoTo 0
MsgBox "End of repair procedure!"
End If
Exit Sub
Err_Repair:
For Each errLoop In DBEngine.Errors
MsgBox "Repair unsuccessful!" & vbCr & _
"Error number: " & errLoop.Number & _
vbCr & errLoop.Description
Next errLoop
End Sub
Sincerely,
Alick Ye, MCSD
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--------------------
| X-Tomcat-NG: microsoft.public.access.macros
|
| Hi,
|
| How can i compact and repair a .MDB file through a macro ?
| I already know how to do that using menu iterface.
|
| Thanks,
| Ali
|
|
|