设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 271|回复: 5
打印 上一主题 下一主题

关于使ACCESS关闭功能真正的控制起来【本人申辩】

[复制链接]
跳转到指定楼层
1#
发表于 2002-4-11 21:52:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本人的确见过该种介绍该方法的英文文章,也绝非张乱说之人,下面就是该文章:
(人家几年前就用了HuangHai兄的方法)

(Q) I want to make sure that users always exit my database using the Exit button provided on my Switchboard. However, I'm not able to prevent them from closing Access itself. Is there a way to control how they exit Access?

(A) You can use the UnLoad event of a form to do this. If your switchboard is the first form to open and always remains open in the background, you can apply the following method on the switchboard. Otherwise, I would recommend creating a hidden form for this functionality.

Define a new variable in a new module

Public pboolCloseAccess as Boolean
'Note: Access 2.0 does NOT recognize Boolean
'type variables. Use integer type instead,
'passing a -1 as True, and 0 as False.


Now, when you open the database, set
pboolCloseAccess=False

In your (Switchboard/Hidden) Form's Unload Event, set the variable to true and also check for its value
pboolCloseAccess=True
DoCmd.Close acForm, "hfrmCloseAccess"
docmd.Quit

If your Switchboard form closes during one instance, then create a new form (hfrmCloseAccess). You can minimize the size if you want because it will be in hidden mode. Type the following in hfrmCloseAccess's OnUnload Event
if not pboolCloseAccess then cancel = true

Create the Autoexec macro. If you already have one, make sure that you open hfrmCloseAccess before anything else IN HIDDEN MODE.

The reasoning here is, when someone clicks X in Access's window, the System starts closing down all open objects in a first-open-last-close basis. Since your hfrmCloseAccess form is the first one to open, it will be the last to close. And since the boolean var is still False, Cancel will always be true, hence Access will not close. On the other hand, when the user clicks on the Exit button or closes your switchboard, you're setting the boolean var to True and then closing the hfrmCloseAccess form, which WILL close now and hence Access will close itself.


分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅

点击这里给我发消息

2#
发表于 2002-4-11 22:18:00 | 只看该作者
我想huanghai兄应该不是抄袭
不过,不得不承认,国内在ACCESS方面的确与国外有一段比较大的距离
但我想这并不妨碍我们学习ACCESS。
我想大家也不必心存压力,但人家好的技术,我们一定要学。
3#
发表于 2002-4-11 23:09:00 | 只看该作者
奇怪,我们是学习不是发明啊,老兄,难道我们要独创一门别人没有的东西???当然,如果引用别人比较完整的成果时候最好要说明一下,以示尊重。

点击这里给我发消息

4#
发表于 2002-4-11 23:31:00 | 只看该作者
正是,如果你知道用的是别人的代码,引用是必要的,如果是巧合,而你本身又不知,
倒也不必在意,还没到吃官司的地步。
其实Ms Access兄也只是说好象见过类似代码,并非指责。
我想我们倒应该把精力放到ACCESS本身的研究上,
不然, 过了几天, 你写的得意代码人家又已经写了好多个
:)
5#
发表于 2002-4-13 03:44:00 | 只看该作者
洋为中用,古为今用,英雄所见略同,没什么大不了的,重要的是能不能提高
6#
发表于 2002-4-13 22:19:00 | 只看该作者
我刚刚认真看了一下上面的那篇文章,我的想法的确和文章写的一样,看来多看一看别人的文章会少很多不必要的思考时间。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-6-5 01:31 , Processed in 0.102108 second(s), 29 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表