如何在关闭事件中取消关闭表单? [英] How to cancel a form close in Close Event?

查看:70
本文介绍了如何在关闭事件中取消关闭表单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我敢肯定这很简单,但是我找不到.在关闭访问表单的情况下,如何取消关闭表单?我有一个对表中的记录进行计数的测试.如果该表中有记录,我想问用户是否要关闭或返回并使用它们.那么如何取消关闭事件?

I'm sure this is very simple, but I can't find it. In the close event of an Access Form, how can I cancel closing the form? I have a test that counts the records in a table. If that table has records, I want to ask the user if they want to close or go back and work with them. So how do I cancel the close event?

推荐答案

您可以使用Unload事件:

You can use the Unload event:

GlobalVar ButtonClicked

Private Sub Form_Open(Cancel As Integer)
     ButtonClicked = False
End Sub

Private ClickMe_Click(Cancel As Integer)
     ButtonClicked = True
End Sub

Private Sub Form_Unload(Cancel As Integer)
     If Not ButtonClicked Then
         Cancel = True
     End if
End Sub  

查看全文

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