Code: Select all
Public Function CompactDB(ByVal sSource As String, ByVal sDest As String) As Boolean
Dim iEngineType As Integer
Dim JRO As JRO.JetEngine
Dim CN As ADODB.Connection
On Error GoTo CompactDB_Error
sSource = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & sSource
Set CN = New ADODB.Connection
With CN
.Open sSource
iEngineType = .Properties("Jet OLEDB:Engine Type")
.Close
End With
Set CN = Nothing
sDest = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Jet OLEDB:Engine Type=" & iEngineType & _
";Data Source=" & sDest
Set JRO = New JRO.JetEngine
JRO.CompactDatabase sSource, sDest
CompactDB = True
Set JRO = Nothing
Kill (STRDBPATH)
On Error GoTo 0
Exit Function
CompactDB_Error:
CompactDB = False
On Error Resume Next
Set CN = Nothing
Set JRO = Nothing
On Error GoTo 0
End Function
note:
i just have a const:
Public Const PSW = "123456789"
i open a database with password with:
Public Sub APRI_CON_MDB()
Set CN = New ADODB.Connection
With CN
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & STRDBPATH & ";" & "Jet OLEDB:Database Password=" & PSW
.Open
End With
End Sub
i think i need tio integrate the piece of bold code in with cn and with... bho?