RE:Compactar .mdb desde Visual
Private Sub mnuCompactaBase_Click()
Dim objAccess As Access.Application, Dos As FileSystemObject
´Creo el objeto ACCESS
Espera.Label1.Caption = "Creando objeto ..."
Espera.Show: Espera.Refresh
Set objAccess = New Access.Application
With objAccess
Espera.Label1.Caption = "Compactando Base ..."
Espera.Refresh
.DBEngine.CompactDatabase "F:\Produc\Laborat.mdb", "F:\Produc\db1.mdb"
End With
objAccess.Quit
Set objAccess = Nothing
´Creo el objeto DOS
Set Dos = New FileSystemObject
With Dos
Espera.Label1.Caption = "Actualizando base final ..."
Espera.Refresh
If .FileExists("F:\Produc\Laborat.mdb") Then .DeleteFile "F:\Produc\Laborat.mdb", True
If .FileExists("F:\Produc\db1.mdb") Then .CopyFile "F:\Produc\db1.mdb", "F:\Produc\Laborat.mdb", True
.DeleteFile "F:\Produc\db1.mdb", True
End With
Set Dos = Nothing
Unload Espera: Set Espera = Nothing
End Sub
Private Sub mnuReparaBase_Click()
Dim objAccess As Access.Application
´Creo el objeto ACCESS
Espera.Label1.Caption = "Creando objeto ..."
Espera.Show: Espera.Refresh
Set objAccess = New Access.Application
With objAccess
Espera.Label1.Caption = "Reparando Base ..."
Espera.Refresh
.DBEngine.RepairDatabase "F:\Produc\Laborat.mdb"
End With
objAccess.Quit
Set objAccess = Nothing
Unload Espera: Set Espera = Nothing
End Sub