- Home
·
- Miscellaneous
·
- Function to Compact the MS Access Database - Passing database name with full path
Function to Compact the MS Access Database - Passing database name with full path
Function to Compact the MS Access Database - Passing database name with full path
API Declarations
' Microsoft Jet and Replication Objects 2.6 Library
Rate Function to Compact the MS Access Database - Passing database name with full path
(1(1 Vote))
' Microsoft Jet and Replication Objects 2.6 Library
Public Function fnCompactDB(strDbPath As String) As Boolean
On Error GoTo LOCALERRORHANDLER
' To Compact the MS Access Database
Dim strMdbTemp As String 'Temporary mdb name
Dim strBackUpMdb As String 'BackUp mdb name
Dim strSourceConnect As String 'Source mdb name with proper format
Dim strDestConnect As String 'Temp mdb name with proper format
Dim jetEngine As jro.jetEngine 'Jet replication object
'initialize the required mdb names
strMdbTemp = MID(gDBName, 1, Len(gDBName) - 4)
strMdbTemp = strMdbTemp & "_tmp.mdb"
strBackUpMdb = strDbPath & "backup.mdb"
'Initialize the data source name
strSourceConnect = "Data Source=" & gDBName
strDestConnect = "Data Source=" & strMdbTemp & ";" & "Jet OLEDB:Encrypt Database=True"
Set jetEngine = New jro.jetEngine
jetEngine.CompactDatabase strSourceConnect, strDestConnect 'Compact the database
If Dir(strBackUpMdb) <> "" Then
Kill strBackUpMdb
End If
Name gDBName As strBackUpMdb
Name strMdbTemp As gDBName
Set jetEngine = Nothing
fnCompactDB = True
Exit Function
LOCALERRORHANDLER:
fnCompactDB = False
End Function
Function to Compact the MS Access Database - Passing database name with full path Comments
No comments yet — be the first to post one!
Post a Comment