Home Page Bahamas Software Bahamas Real Estate Bahamas Writer Business Services Contact Us

Computer Repair
Tel: 242-364-9183
Nassau, Bahamas
Bahamas Video Surveillance . Bahamas CCTV . Bahamas Infrared . Bahamas Digital Video . Bahamas Remote Video . Bahamas Burglar Alarm . Bahamas Technician
Bahamas Real Estate
Bahamas Yellow Pages


Free Software:


We Recommend:
MediaFire - Free File Hosting Made Simple
Follow us on:
Twitter Twitter
Compact MS Access Database
Option Explicit

Private Sub Command1_Click()
    Dim sText As String
    sText = Compact("c:\myFile.mdb", "mypass")
    If Len(sText) Then
        Debug.Print sText
    Else
        Debug.Print "Compacted"
    End If
End Sub

Public Function Compact(Source As String, _
    Password As String) As String
On Error GoTo ErrHandler:
    Dim objJet As JRO.JetEngine
    Dim Destination As String
    Static Compacting As Boolean
    If Right(LCase(Source), 4) = ".mdb" And Not Compacting Then
        Compacting = True
        If LenB(Dir$(Source)) > 0 Then
            Destination = App.Path & "\" & Format(Now, "hhmmssmmddyy") & ".tmp"
            If LenB(Dir$(Destination)) Then Kill Destination
            Set objJet = New JRO.JetEngine
            DoEvents: objJet.CompactDatabase _
                "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Source & ";" & _
                "Jet OLEDB:Database Password=" & Password & ";", _
                "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Destination & ";" & _
                "Jet OLEDB:Database Password=" & Password & ";"
            Set objJet = Nothing
            Kill Source: Name Destination As Source
            Compact = vbNullString
        Else
            Compact = "FILE PATH ERROR"
        End If
        Compacting = False
    Else
        If Compacting Then
            Compact = "BUSY COMPACTING"
        Else
            Compact = "INVALID DATABASE"
        End If
    End If: Exit Function
ErrHandler:
    Set objJet = Nothing
    Compact = UCase(Err.Description)
    Compacting = False
End Function

 

Bahamas CCTV . Bahamas DVR . Bahamas Camera . Bahamas Video . Bahamas Computer Repair . Bahamas Software . Bahamas Business . Bahamas Real Estate
Copyright (c) 2001/2010 BahamasSecurity.com