Jobs
Author: Raghuraja. C Date Submitted: 2/17/2005 Category: Other Compatibility: VB 6 This code has been accessed 5036 times.
Email Yourself this snippet:
'Please Include the Project Reference Following object ' Microsoft Jet and Replication Objects 2.6 Library
Code
'Please Include the Project Reference Following object ' 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