紧密压缩的有趣方法 [英] Interesting approach for compacting on close

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

问题描述

为了进一步跟进我关于docmd.quit与

Application.quit使用access 2007的上一篇文章,我注意到docmd.quit将正确

compact数据库(程序文件),如果您为当前数据库设置了紧密关闭

选项。


但是,即使Compact on Close设置,如果你使用Application.Quit

acQuitSaveNone,压缩将不会触发。


这种行为实际上似乎是可取的,因为你现在可以制作一个程序

退出程序时更聪明。如果你有一个退出按钮执行

一些管家类型的过程,备份等,然后退出访问程序,

你可以利用上面的行为(docmd .quit与

application.quit)确定你是否应该紧凑。


要做到这一点,请确保Compact on Close设置为当前数据库

(您的访问程序文件),然后在退出时运行以下功能

按钮。


希望这可以帮助那些可能一直在寻找类似解决方案的人。

这种行为适用于Access 2007,但我不确定2003年。

公共功能ExitButton()As Boolean

Dim progsize As Long,compactyn As Integer

progsize = FileLen(CurrentDb.Name)

如果progsize 40000000那么' '= 40 MB。你设置一个合理的数字

认为该程序应该被压缩

compactyn = -1

否则

compactyn = 0

结束如果

''MsgBox"程序大小现在是:" &安培;进步与推进"字节。设置紧凑的

接近: &安培; compactyn

''调用AutomatedBU(0)''运行你的任何过程等。

''调用CloseOpenTabs''关闭所有开放表格的例行程序/>
''

Exit_btnExit_Click:

''

如果compactyn = -1那么

DoCmd.Quit''docmd.quit将正确运行紧凑的

Else

Application.Quit acQuitSaveNone''无论出于何种原因,这个命令

忽略紧凑时关闭设置

结束如果

''

''退出功能


Err_btnExit_Click:

如果Err = 2450那么''用户在预览报告时mistankingly关闭

退出功能

ElseIf Err = 2501然后

继续下一步

Else

MsgBox Err.Description& " - &安培; Err.Number& ",功能:

ExitButton",vbCritical

恢复Exit_btnExit_Click

结束如果

结束功能

To further follow up on my last post regarding the docmd.quit vs.
Application.quit using access 2007, I noticed that docmd.quit will correctly
compact the database (program file) if you have the "Compact on Close"
option set for the current database.

However, even with Compact on Close set, if you use the Application.Quit
acQuitSaveNone, the compacting will not fire.

This behavior actually seems desirable, as you can now make a program
smarter upon exiting your program. If you have an exit button that performs
some housekeeping type procs, backup, etc., then exits the access program,
you can take advantage of the behavior above (docmd.quit vs.
application.quit) to determine if you should compact.

To do this, make sure "Compact on Close" is set for the current database
(your access program file), then run the following function on your exit
button.

Hope this helps people who might have been looking for a similar solution.
This behavior works in Access 2007, but I''m not sure about 2003.
Public Function ExitButton() As Boolean
Dim progsize As Long, compactyn As Integer
progsize = FileLen(CurrentDb.Name)
If progsize 40000000 Then ''=40 MB. Set a reasonable number where you
think the program should be compacted
compactyn = -1
Else
compactyn = 0
End If
''MsgBox "Program size is now: " & progsize & " bytes. Setting compact on
close to: " & compactyn
''Call AutomatedBU(0) ''run any of your procs, etc.
''Call CloseOpenTabs ''a routine to close out all open forms
''
Exit_btnExit_Click:
''
If compactyn = -1 Then
DoCmd.Quit ''the docmd.quit will correctly run the compact on close
Else
Application.Quit acQuitSaveNone ''For whatever reason, this command
Ignores the "Compact on Close" setting
End If
''
'' Exit Function

Err_btnExit_Click:
If Err = 2450 Then ''user mistankingly closed while previewing a report
Exit Function
ElseIf Err = 2501 Then
Resume Next
Else
MsgBox Err.Description & " - " & Err.Number & ", Function:
ExitButton", vbCritical
Resume Exit_btnExit_Click
End If
End Function

推荐答案

Andy写道:
Andy wrote:

要进一步跟进我上一篇关于docmd.quit与

Application.quit使用access 2007,我注意到docmd.quit将

正确压缩数据库(程序文件)如果你有

Compact on Close为当前数据库设置的选项。
To further follow up on my last post regarding the docmd.quit vs.
Application.quit using access 2007, I noticed that docmd.quit will
correctly compact the database (program file) if you have the
"Compact on Close" option set for the current database.



大多数有经验的开发人员认为Compact-On-Close充其量只是无用的b
更多,这是一个非常糟糕的主意。 />

-

Rick Brandt,Microsoft Access MVP

电子邮件(视情况而定)至...

在Hunter dot的RBrandt com

Most experienced developers consider Compact-On-Close to be at best, useless
and more often, a pretty bad idea.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com


我很欣赏这个评论并且之前已经阅读了类似的评论,但是,如果

前端发生任何事情在紧凑的情况下,最糟糕的情况是你获得了一张新的FE副本。


紧凑的关闭对BE没有任何影响,它仅适用于你打开的文件是
,而不是链接的桌子等等。


你能举例说明为什么这是个坏主意吗?


" Rick Brandt" < ri ********* @ hotmail.comwrote in message

news:WY **************** @ flpi147.ffdc。 sbc.com ...
I appreciate the comment and have read similar comments before, however, if
anything happens to the front-end on the compact, worst case is you grab a
new copy of the FE.

Compact on close has no affect on the BE, it only operates on the file you
have opened, not linked tables, etc.

Can you give examples of why it''s a bad idea?

"Rick Brandt" <ri*********@hotmail.comwrote in message
news:WY****************@flpi147.ffdc.sbc.com...

Andy写道:
Andy wrote:

>进一步跟进我的上一次关于docmd.quit与使用Access 2007的Application.quit的帖子,我注意到如果你有
Compact,docmd.quit将正确压缩数据库(程序文件)关闭"为当前数据库设置的选项。
>To further follow up on my last post regarding the docmd.quit vs.
Application.quit using access 2007, I noticed that docmd.quit will
correctly compact the database (program file) if you have the
"Compact on Close" option set for the current database.



大多数经验丰富的开发人员认为Compact-On-Close充其量只是,b $ b无用且更常见,这是一个非常糟糕的主意。 />

-

Rick Brandt,Microsoft Access MVP

电子邮件(视情况而定)至...

Hunter dot的RBrandt


Most experienced developers consider Compact-On-Close to be at best,
useless and more often, a pretty bad idea.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com


" Andy" < PC ***** @ PCESoft.invalidwrote in message

news:IN **************** @ flpi150.ffdc.sbc.com。 ..
"Andy" <PC*****@PCESoft.invalidwrote in message
news:IN****************@flpi150.ffdc.sbc.com...

为了进一步跟进我上一篇关于使用access 2007的docmd.quit与

Application.quit的帖子,我注意到了docmd.quit将

正确压缩数据库(程序文件),如果你有Compact on

Close为当前数据库设置的选项。


但是,即使使用Compact on Close设置,如果使用Application.Quit

acQuitSaveNone,压缩也不会触发。
To further follow up on my last post regarding the docmd.quit vs.
Application.quit using access 2007, I noticed that docmd.quit will
correctly compact the database (program file) if you have the "Compact on
Close" option set for the current database.

However, even with Compact on Close set, if you use the Application.Quit
acQuitSaveNone, the compacting will not fire.



嗯...我刚刚在A2003尝试过它*它确实*有效。你是最新的

SP和类似物吗?


基思。
www.keithwilby.com

Hmm ... I''ve just tried it in A2003 and it *does* work. Are you up to date
with SPs and the like?

Keith.
www.keithwilby.com


这篇关于紧密压缩的有趣方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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