问题描述
带有所有补丁的Windows 7旗舰版x64以及
带有所有补丁的Office 2010专业版
Windows 7 Ultimate x64 with all patches
Office 2010 Pro with all patches
我正在尝试调试某些内容并创建了一个简单的表单带有两个未绑定的CheckBoxes:Check0和Check2
目的是使用Check2的值来允许更改Check0或阻止它被更改。
I am trying to debug something and have created a simple form with two unbound CheckBoxes: Check0 and Check2
The intent is to use the value of Check2 to either allow Check0 to be changed or stop it from being changed.
表单背后的代码如下:
Option Compare Database
Option Explicit
Private Sub Check0_BeforeUpdate(Cancel As Integer)
Debug.Print "BeforeUpdate0: " & Check0.Value
If (Check2.Value) Then
Cancel = True
End If
End Sub
Private Sub Check0_Click()
Debug.Print "Click0: " & Check0.Value
End Sub
Private Sub Check0_AfterUpdate()
Debug.Print "AfterUpdate0: " & Check0.Value
End Sub
Private Sub Check2_AfterUpdate()
Debug.Print "AfterUpdate2: " & Check2.Value
End Sub
Private Sub Check2_BeforeUpdate(Cancel As Integer)
Debug.Print "BeforeUpdate2: " & Check2.Value
End Sub
Private Sub Check2_Click()
Debug.Print "Click2: " & Check2.Value
End Sub
以下点击产生即时窗口中显示的输出。
The following clicks produce the shown output in the immediate windows.
Check0
BeforeUpdate0:-1
AfterUpdate0:-1
Click0:-1
(Check0现在显示一个选中标记)
Check0
BeforeUpdate0: -1
AfterUpdate0: -1
Click0: -1
(Check0 now shows a checkmark)
Check2
BeforeUpdate2:-1
AfterUpdate2:-1
Click2:-1
(Check2现在显示一个复选标记)
Check2
BeforeUpdate2: -1
AfterUpdate2: -1
Click2: -1
(Check2 now shows a checkmark)
Check0
BeforeUpdate0:0
(Check0仍显示复选标记)
Check0
BeforeUpdate0: 0
(Check0 still shows a checkmark)
Check2
BeforeUpdate0:-1
(Check2仍显示复选标记)
Check2
BeforeUpdate0: -1
(Check2 still shows a checkmark)
请注意,虽然最后一次点击是在Check2上,但是触发的Check0_BeforeUpdate事件不是Check2_BeforeUpdate
Please note that although the last click was on Check2 it is Check0_BeforeUpdate event that is fired not Check2_BeforeUpdate
此外,当我点击关闭时表单我得到以下错误消息,即使控件是未绑定的:
Furthermore, when I click on Close for the form I get the following error message even through the controls are unbound:
任何解释都会有所帮助。
Any explaination would be appreciate.
推荐答案
这篇关于带有两个复选框的表单 - 错误的BeforeUpdate事件触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!