vba 在 Access 2007/2010 中启用和禁用对连续子窗体的控制
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11507151/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Enabling and disabling controls on a Continuous Subform in Access 2007/2010
提问by Sinister Beard
I need to enable or disable a control on a continuous subform, dependent on another field. The initial code I wrote by instinct was very similar to what is suggested here, but instead of only disabling those controls which are marked as "child", it disables all of them - in effect, it seems only to be looking for the value of the last record and affecting all the rows.
我需要启用或禁用依赖于另一个字段的连续子表单上的控件。我由本能编写的初始代码与此处建议的非常相似,但它不仅禁用标记为“子”的控件,还禁用所有控件 - 实际上,它似乎只是在寻找最后一条记录并影响所有行。
Is there a way this can be achieved, or am I barking up the wrong tree? Code below:
有没有办法做到这一点,或者我在吠错树?代码如下:
If Me.Record_Type = "Child" Then 'Disable subsidiary records
Me.Record_Type.SetFocus
Me.Prospect_Name.Enabled = False
End If
回答by Fionnuala
The only way of sensibly working with rows in a continuous form is with Conditional Formatting. Any code applied refers to the active row, and so it appears to affect all rows.
以连续形式处理行的唯一方法是使用Conditional Formatting。任何应用的代码都指向活动行,因此它似乎会影响所有行。
Conditional Formatting, Access 2010
条件格式,Access 2010
Enable / Disable is selected
启用/禁用被选中