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

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

问题描述

很简单的问题,我知道。

解决方案

如果要压缩/修复外部mdb文件(而不是刚刚工作的文件) p>

  Application.compactRepair sourecFile,destinationFile 

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

  Application.SetOptionAuto compact ,True 

在这种情况下,您的应用程序将在关闭文件时压缩。

我的意见:在一个额外的MDBcompacter文件中编写几行代码,当你想压缩/修复一个mdb文件时,你可以调用它是非常有用的:在大多数情况下



否则,默认情况下,autocompact将被设置为true,因此需要压缩的文件不能正常打开,因此您需要从文件外部调用该方法。在访问应用程序的每个主模块中。



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


Pretty simple question, I know.

解决方案

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.

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.

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

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天全站免登陆