|
'在程序退出前调用下面代码,即可实现当文件到达一定大小才压缩数据库
Public Function AutoCompactCurrentProject()
Dim fs, f, s, filespec
Dim strProjectPath As String, strProjectName As String
strProjectPath = Application.CurrentProject.Path
strProjectName = Application.CurrentProject.Name
filespec = strProjectPath & "\" & strProjectName
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(filespec)
s = CLng(f.Size / 1000000) '转换成MB
If s > 20 Then
Application.SetOption ("Auto Compact"), 1 '压缩
Else
Application.SetOption ("Auto Compact"), 0 '不压缩
End If
End Function
上面的代码为当文件到达一定大小时才执行退出压缩,稍改一下就能实现楼主的要求 |
|