MS Access:如何在 VBA 中压缩当前数据库 [英] MS Access: how to compact current database in VBA

查看:81
本文介绍了MS Access:如何在 VBA 中压缩当前数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很简单的问题,我知道.

Pretty simple question, I know.

推荐答案

如果您想压缩/修复外部 mdb 文件(不是您刚刚使用的文件):

If you want to compact/repair an external mdb file (not the one you are working in just now):

Application.compactRepair sourecFile, destinationFile

如果你想压缩你正在使用的数据库:

If you want to compact the database you are working with:

Application.SetOption "Auto compact", True

在最后一种情况下,您的应用将在关闭文件时被压缩.

In this last case, your app will be compacted when closing the file.

我的观点:在一个额外的MDB压缩器"文件中写几行代码,当你想压缩/修复一个mdb文件时可以调用它非常有用:在大多数情况下,需要压缩的文件不能被正常打开了,需要在文件外调用该方法.

My opinion: writting a few lines of code in an extra MDB "compacter" file that you can call when you want to compact/repair an mdb file is very usefull: in most situations the file that needs to be compacted cannot be opened normally anymore, so you need to call the method from outside the file.

否则,默认情况下,在 Access 应用程序的每个主要模块中,自动压缩应设置为 true.

Otherwise, the autocompact shall by default be set to true in each main module of an Access app.

如果发生灾难,请创建一个新的 mdb 文件并从错误文件中导入所有对象.您通常会发现无法导入的错误对象(表单、模块等).

In case of a disaster, create a new mdb file and import all objects from the buggy file. You will usually find a faulty object (form, module, etc) that you will not be able to import.

这篇关于MS Access:如何在 VBA 中压缩当前数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆