Make the access file larger than the specified large-hour automatic compression

Source: Internet
Author: User
Tags compact

Applicable Access2000 and later versions

Translation: Tmtony (access/office China)

The following functions are added first in the public module:

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 ‘修改此处的20M为你自己需要的值
Application.SetOption ("Auto Compact"), 1 ‘压缩程序
Else
Application.SetOption ("Auto Compact"), 0 ‘不压缩程序
End If
End Function

Call this function before any exiting program, for example, before Docmd.quit:

Autocompactcurrentproject

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.