在没有表单的情况下关闭DB运行查询??? [英] Run Queries on Close of DB without Form ???!!!

查看:71
本文介绍了在没有表单的情况下关闭DB运行查询???的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我希望在关闭数据库时运行一些查询,例如函数关闭时修复。但我不想使用带有VBA代码或命令按钮的表单。有没有其他可能性?? !!

提前感谢您的答案:)

解决方案

我不相信有一个方式 - 我已经浏览了一下,但是如果有人找到方法,我会兴趣地看这个帖子。

非常有趣的问题BTW。


< blockquote>没有直接的方法。然而,这是一个具有相同效果的解决方法


1 - 创建一个空白表单

2 - 在其卸载事件中运行您要执行的代码当数据库关闭时。

3 - 将表单可见属性设置为False,使其不可见

4 - 创建一个autoexec宏,在数据库打开时无形地打开表单。


如果这样做,关闭数据库将卸载隐藏的表单并触发数据库关闭时要执行的代码。


嗨安德鲁,

这真的是一个很好的间接方式:)我只有一个问题。用户可以按屏幕上的小x按钮关闭数据库。如果数据库没有退出应用程序的表单,他们实际上总是这样做。你确定点击这个小x会以隐藏的形式运行unload事件吗?我问,因为我已经尝试了类似的东西,似乎没有工作。但也许我错过了一些东西并且弄错了......?



没有直接的方法。然而,这是一个具有相同效果的解决方法


1 - 创建一个空白表单

2 - 在其卸载事件中运行您要执行的代码当数据库关闭时。

3 - 将表单可见属性设置为False,使其不可见

4 - 创建一个autoexec宏,在数据库打开时无形地打开表单。


如果这样做,关闭数据库将卸载隐藏的表单并触发数据库关闭时要执行的代码。


Hi,
I want to have some queries run on close of my database like the function "Repair on Close" But I don''t want to use a form with VBA code or command buttons doing it. Is there any other possibility ??!!
Thanks in advance for answers :)

解决方案

I don''t believe there is a way - I''ve had a look around, but I''ll watch this thread with interest in case someone finds a way.
Very interesting question BTW.


There is no direct way. However this is a workaround that has the same effect

1 - create a blank form
2 - In its on Unload event run the code you want to execute when the database closes.
3 - set the forms visible properties to False so it is invisible
4 - create an autoexec macro that opens the form invisibly when the database opens.

If you do this closing the database will unload the hidden form and trigger the code you want to execute when the database closes.


Hi Andrew,
that''s really a good indirect way :) I have just one question. User can close the database pressing the little x-button on the screen. They actually always do it, if the database doesn''t have a form exiting the application. Are you sure that hitting this little x will run the unload event in the hidden form? I ask because I tried something like that already and it didn''t seem to workmout. But maybe I missed something and made it wrong...?


There is no direct way. However this is a workaround that has the same effect

1 - create a blank form
2 - In its on Unload event run the code you want to execute when the database closes.
3 - set the forms visible properties to False so it is invisible
4 - create an autoexec macro that opens the form invisibly when the database opens.

If you do this closing the database will unload the hidden form and trigger the code you want to execute when the database closes.


这篇关于在没有表单的情况下关闭DB运行查询???的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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