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