用户使用(x)关闭数据库时运行VBA代码 [英] Running VBA code when a user closes database using (x)

查看:99
本文介绍了用户使用(x)关闭数据库时运行VBA代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如屏幕右上角的(x)那样。


我有一个注销和退出按钮,它会从列表中删除用户以告诉我谁登录谁不是,但无论我问多少次,人们仍然使用(x)关闭数据库,而不是退出。


有没有无论何时数据库关闭都运行相同代码的方法?

As in the (x) in the top right hand corner of the screen.

I have a log out and Exit button, which removes users from a list to let me know who is logged in and who isn''t, however no matter how many times I ask, people still close the database using the (x), rather than logout.

Is there any way to run the same code when the database closes regardless?

推荐答案

我有一个表单frm_Startup在启动时打开,并执行各种操作。其中一个操作是以隐藏模式打开frm_ControlClose(不可见)。 frm_ControlClose的CLOSE事件附加了代码,用于注销用户。我们的想法是,当用户使用(x)关闭时,所有表单都会被访问关闭,包括不可见的表单。
I have a form frm_Startup that opens on startup, and does various actions. One of those actions is to open frm_ControlClose in hidden mode (not visible). The CLOSE event of frm_ControlClose has code attached to it, to logout the user. The idea is that when the user closes using the (x) all forms gets closed by access including the non-visible form.


因此,如果用户使用(x)所有表单关闭数据库实际上运行他们的vba?


我可以在主屏幕附近附加一个,它总是打开的,如果是这样的话,它会运行注销代码case。
So if a user closes the database using (x) all forms with a on close stipulation actually run their vba?

I could attach an on close to the main screen, which is always open, and that would then run the logout code if this was the case.


你也可以这样做。


我在查看特定项目时有时会关闭主窗体,所以这就是为什么我以单独的形式这样做。
Yup you could do that as well.

I sometimes have the main form close when viewing specific items, so thats why I do it that way with a seperate form.


这篇关于用户使用(x)关闭数据库时运行VBA代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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