gpt4 book ai didi

ms-access - VBA:为什么我每次都必须设置焦点来控制?

转载 作者:行者123 更新时间:2023-12-03 23:06:44 24 4
gpt4 key购买 nike

我正在使用 Access 2007 数据库创建个人图书馆库存系统。在代码中,每当我引用 .Text表单控件的属性,无论是更改值,还是只是检查 IF 语句中的值,我都会收到 Run-time error '2185': You can't reference a property or method for a control unless the control has the focus 的提示.

为什么是这样?

用于设置 .Text这不是什么大问题,但是当我检查 IF 语句中的值时,当我检查多个条件时,我无法设置焦点。

最佳答案

使用.Value相反 - 这不需要先设置焦点。从文档中,例如 TextBox control (强调我的):

While the control has the focus, the Text property contains the text data currently in the control; the Value property contains the last saved data for the control. When you move the focus to another control, the control's data is updated, and the Value property is set to this new value. The Text property setting is then unavailable until the control gets the focus again.

关于ms-access - VBA:为什么我每次都必须设置焦点来控制?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17306200/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com