Hi all,
Is it possible to programatically "Compact and Repair" an mdb file as can be done manually from MSACCESS menu "Tools"-> "Database Utilities" -> "Compact and Repair Database..."
Any help will be appreciated...

Rajesh Khanna

please find a related discussion here.

Hi all,
Is it possible to programatically "Compact and Repair" an mdb file as can be done manually from MSACCESS menu "Tools"-> "Database Utilities" -> "Compact and Repair Database..."
Any help will be appreciated...

Rajesh Khanna

Apparently, Yes.

http://office.microsoft.com/en-gb/access/HA010345701033.aspx?pid=CL100570041033

"Run Microsoft Visual BasicĀ® for Applications (VBA) code that uses the CompactDatabase method of either Microsoft Jet and Replication Objects (JRO) or Microsoft Data Access Objects (DAO)."

'Compact the database
    DB_sour = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
        & strSourcePath & ";" & "Jet OLEDB:Database Password=" & strPassword
& ";"

    DB_dest = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
            & strTempFile & " ;Jet OLEDB:Engine Type=5;" & _
            "Jet OLEDB:Database Password=" & strPassword & ";"

    JROje.CompactDatabase DB_sour, DB_dest
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.