在VBA Access中使用.text和.value的区别 [英] Distinction between using .text and .value in VBA Access
问题描述
我正在将textbox1.text
值传递给查询,有时甚至传递给字符串:
I am passing the textbox1.text
values into a query and sometimes into a string:
Dim combor1 As String
combor1 = comboReason1.Text
我怎么知道什么时候应该放combor1 = comboReason1.Value
?
How do I know when I should put combor1 = comboReason1.Value
?
此外,为什么我需要为控件设置焦点以引用其属性?这对我来说没有意义.
Also, why do I need to set focus for a control to reference its property? That doesn't make sense to me.
此外,当我将combor4 = comboReason4.Value
设置为.value
时,会出现有关无效使用null的错误.
Also, when I set combor4 = comboReason4.Value
and the .value
is null, then I get an error about invalid use of null.
推荐答案
- .text"为您显示的内容 在屏幕上
- .value"为您提供了基础 值
- ".text" gives you what is displayed on the screen
- ".value" gives you the underlying value
- 组合框或列表框控件
- 显示的值与绑定列不同
- id_Person是一种形式的组合框控件
- 行源为"SELECT id_Person,Tab_Person的personName"
- 列宽为"0cm; 3cm"
- 绑定列为1
- id_Person.text显示Tbl_Person.personName
- id_Person.value显示Tbl_Person.id_Person.
通常两者都给出相同的结果,除非相应的控件为
Both usually give the same result, except when the corresponding control is
示例:
在这种情况下:
.text属性仅在相应控件具有焦点时可用.
.text property is available only when the corresponding control has the focus.
.text是字符串值,因此不能为Null,而.value可以为Null
.text is a string value, therefore it cannot be Null, while .value can be Null
.text只能在控件具有焦点时调用,而.value可以在任何时候调用...
.text can only be called when the control has the focus, while .value can be called any time ...
这篇关于在VBA Access中使用.text和.value的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!