by Raghuraja. C (21 Submissions)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Thu 17th February 2005
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Function to Compact the MS Access Database - Passing database name with full path
API Declarations
' Microsoft Jet and Replication Objects 2.6 Library
' 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
No comments have been posted about Function to Compact the MS Access Database - Passing database name with full path. Why not be the first to post a comment about Function to Compact the MS Access Database - Passing database name with full path.