VBA - 禁用对另一种形式的控制

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11842559/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 17:12:13  来源:igfitidea点击:

VBA - Disable control on another form

vbams-access

提问by JMK

Quite simply, I want to disable a textbox on another form with VBA.

很简单,我想用 VBA 禁用另一个表单上的文本框。

I know that I can open my form like so:

我知道我可以像这样打开我的表单:

DoCmd.OpenForm "frmMyForm"

I can access the value contained in a textbox on my form like so

我可以像这样访问表单上文本框中包含的值

Dim myValue As String
myValue = [Forms]![frmMyForm]![txtMyControl]

I can update the value like so:

我可以像这样更新值:

[Forms]![frmMyForm]![txtMyControl] = "FooBar"

How do I disable the textbox (as in set the Enabledproperty to false)?

如何禁用文本框(如将Enabled属性设置为 false)?

Thanks

谢谢

回答by JMK

I'm an idiot, it turns out all you do is this:

我是个白痴,事实证明你所做的就是这样:

[Forms]![frmMyForm]![txtMyControl].Enabled = False