紧凑型代码? [英] Code For Compact On Close?

查看:98
本文介绍了紧凑型代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在关闭时仅在数据库大小超过一定金额而不是每次的时候压缩。因此,我想检查文件大小

,然后在mdb关闭时执行紧凑的代码。那是

可能吗?


我想一个选项就是在

总机中设置Compact On Close选项'' s关闭事件,然后在数据库打开时打开它。这可能会奏效。但我更喜欢一个更清洁的解决方案,我可以在数据库关闭的时候调用紧凑的函数(我在猜测这是不是
这不是可能......)。


谢谢。

I would like to compact on close only if the database size goes over a
certain amount, rather than each time. Thus, I''d like to check the file size
and then perform the compact through code as the mdb''s closing. Is that
possible?

I suppose one option would be to set the Compact On Close option in the
switchboard''s On Close event, and then clear it whenever the database is
opened. That would probably work. But I''d prefer a cleaner solution, where I
can just call the compact function as the database is closing (I''m guessing
this isn''t possible...).

Thanks.

推荐答案




有人给了我这个功能:


公共功能AutoCompactApplication()


Dim s

昏暗strProjectPath As String,strProjectName As String

strProjectPath = Application.CurrentProject.Path

strProjectName = Application.CurrentProject.Name

filespec = strProjectPath& " \" &安培; strProjectName


s = CLng(FileLen(filespec)/ 1000000)''转换大小


如果是20然后''编辑20(Mb 's)你希望允许的最大尺寸

你的应用程序增长。


Application.SetOption(" Auto Compact),1' '紧凑型应用


否则


Application.SetOption(Auto Compact),0''不要紧凑应用


结束如果


结束功能


当数据库关闭时调用该函数。 />
Neil写道:
Hi

Someone gave me this function:

Public Function AutoCompactApplication()

Dim s
Dim strProjectPath As String, strProjectName As String

strProjectPath = Application.CurrentProject.Path
strProjectName = Application.CurrentProject.Name
filespec = strProjectPath & "\" & strProjectName

s = CLng(FileLen(filespec) / 1000000) ''convert size

If s 20 Then ''edit the 20 (Mb''s) to the max size you want to allow
your app to grow.

Application.SetOption ("Auto Compact"), 1 ''compact app

Else

Application.SetOption ("Auto Compact"), 0 ''no don''t compact app

End If

End Function

Call the function when your DB closes down.
Neil wrote:

>我想在关闭时仅在数据库大小超过一定数量时进行压缩,而不是比每一次。因此,我想检查文件大小
然后执行紧凑的代码作为mdb的关闭。这是否可能?

我想一个选项是在
交换机的On Close事件中设置Compact On Close选项,然后在数据库中清除它是打开的。这可能会奏效。但我更喜欢一个更清洁的解决方案,我可以在数据库关闭时调用紧凑功能(我猜这是不可能的......)。 />
谢谢。
>I would like to compact on close only if the database size goes over a
certain amount, rather than each time. Thus, I''d like to check the file size
and then perform the compact through code as the mdb''s closing. Is that
possible?

I suppose one option would be to set the Compact On Close option in the
switchboard''s On Close event, and then clear it whenever the database is
opened. That would probably work. But I''d prefer a cleaner solution, where I
can just call the compact function as the database is closing (I''m guessing
this isn''t possible...).

Thanks.



-

通过 http://www.accessmonster.com

--
Message posted via http://www.accessmonster.com


建议你声明变量s作为Long数据类型,如
Dim s As Long


将其保留为未声明意味着它是默认数据类型Variant,它是< b / b
不那么有效。


hth

" biganthony via AccessMonster.com" < u31673 @ uwewrote in message

news:7a5ae5bec164f @ uwe ...
suggest you declare the variable "s" as a Long data type, as

Dim s As Long

leaving it undeclared means it is the default data type Variant, which is
less effecient.

hth
"biganthony via AccessMonster.com" <u31673@uwewrote in message
news:7a5ae5bec164f@uwe...




有人给了我这个功能:


公共功能AutoCompactApplication()

Dim s

Dim strProjectPath As String,strProjectName As String


strProjectPath = Application.CurrentProject.Path

strProjectName = Application.CurrentProject.Name

filespec = strProjectPath &安培; " \" &安培; strProjectName


s = CLng(FileLen(filespec)/ 1000000)''转换大小


如果是20然后''编辑20(Mb 's)你希望允许的最大尺寸

你的应用程序增长。


Application.SetOption(" Auto Compact),1' '紧凑型应用


否则


Application.SetOption(Auto Compact),0''不要紧凑应用


结束如果


结束功能


当数据库关闭时调用该函数。 />

Neil写道:
Hi

Someone gave me this function:

Public Function AutoCompactApplication()

Dim s
Dim strProjectPath As String, strProjectName As String

strProjectPath = Application.CurrentProject.Path
strProjectName = Application.CurrentProject.Name
filespec = strProjectPath & "\" & strProjectName

s = CLng(FileLen(filespec) / 1000000) ''convert size

If s 20 Then ''edit the 20 (Mb''s) to the max size you want to allow
your app to grow.

Application.SetOption ("Auto Compact"), 1 ''compact app

Else

Application.SetOption ("Auto Compact"), 0 ''no don''t compact app

End If

End Function

Call the function when your DB closes down.
Neil wrote:

我想在关闭时压缩,只要数据库大小超过

一定金额,而不是每次。因此,我想检查文件$ ​​b $ b
I would like to compact on close only if the database size goes over a
certain amount, rather than each time. Thus, I''d like to check the file



size

size


然后在mdb结束时通过代码执行压缩。那是

可能吗?


我想一个选项就是在

总机中设置Compact On Close选项'' s关闭事件,然后在数据库打开时打开它。这可能会奏效。但我更喜欢更清洁的解决方案,
and then perform the compact through code as the mdb''s closing. Is that
possible?

I suppose one option would be to set the Compact On Close option in the
switchboard''s On Close event, and then clear it whenever the database is
opened. That would probably work. But I''d prefer a cleaner solution,



其中我

where I


可以在数据库关闭时调用紧凑函数(我是
can just call the compact function as the database is closing (I''m



猜测

guessing


这是不可能的......)。


谢谢。
this isn''t possible...).

Thanks.



-

通过 http://www.accessmonster.com



在comp.databases.ms-access中回答。

Neil < no **** @ nospam.netwrote in message

新闻:PZ **************** @ newssvr25.news.prodigy.net .. 。
answered in comp.databases.ms-access.
"Neil" <no****@nospam.netwrote in message
news:PZ****************@newssvr25.news.prodigy.net ...

我想在关闭时压缩,只要数据库大小超过

一定数量,而不是每次。因此,我想检查文件$ ​​b $ b
I would like to compact on close only if the database size goes over a
certain amount, rather than each time. Thus, I''d like to check the file



size

size


然后执行紧凑代码作为mdb的结束。那是

可能吗?


我想一个选项就是在

总机中设置Compact On Close选项'' s关闭事件,然后在数据库打开时打开它。这可能会奏效。但我更喜欢更清洁的解决方案,其中
and then perform the compact through code as the mdb''s closing. Is that
possible?

I suppose one option would be to set the Compact On Close option in the
switchboard''s On Close event, and then clear it whenever the database is
opened. That would probably work. But I''d prefer a cleaner solution, where




I


可以调用紧凑功能当数据库正在关闭时(我是
can just call the compact function as the database is closing (I''m



猜测

guessing


这是不可能的。 ..)。


谢谢。

this isn''t possible...).

Thanks.



这篇关于紧凑型代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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