Compact and Repair

dadrew

Registered User.
Local time
Today, 01:37
Joined
Sep 15, 2003
Messages
186
I had a piece of code that I found on the forum the other day to do a Compact and Repair and the press of a button. Unfortunatly I have lost the code, can anyone advise me please?
 
Ideal, thank you
 
You can turn on or off the AutoCompact option with the
Application.SetOption ("Auto Compact") option

Code:
Public Function AutoCompact()
On Error GoTo Err_AutoCompact
    
    If FileLen(CurrentDb.Name) > 30000000 Then '30 megabytes
        Application.SetOption ("Auto Compact"), 1
    Else
        Application.SetOption ("Auto Compact"), 0
    End If
    
Exit_AutoCompact:
    Exit Function
    
Err_AutoCompact:
    If Err = 2091 Then '"Auto Compact" is an invalid name
        MsgBox "Error 2901 triggered in Access 97"
    Else
        MsgBox Err.Number & " - " & Err.Description
        Resume Exit_AutoCompact
    End If
    
End Function
 

Users who are viewing this thread

Back
Top Bottom