SQL MS Access 中列表框的 BOUND COLUMN 属性的用途是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1360567/
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
What is the purpose of BOUND COLUMN property of listbox in MS Access?
提问by l--''''''---------''''''''''''
What is the purpose of BOUND COLUMN property of listbox?
列表框的 BOUND COLUMN 属性的目的是什么?
回答by Albert D. Kallal
The bound column is a number that represents what column from the row source will be used to set the value of the Control Source (if the list box is bound).
绑定列是一个数字,表示行源中的哪一列将用于设置控件源的值(如果绑定了列表框)。
Note that you can't use a column name here. So you don't set the bound column to a column name, but you must use a column number.
请注意,您不能在此处使用列名。因此,您不必将绑定列设置为列名,但必须使用列号。
Another issue here is that the column number starts at 1 (not zero). Note that OFTEN the 1st column length is set to zero. That allows you to have a list box with something like
这里的另一个问题是列号从 1(不是零)开始。请注意,第一列长度通常设置为零。这允许你有一个类似的列表框
select PartNumber, PartDescripton from tblParts
The list box will display the part description, but if you set the bound column = 1, then the listbox will return the PartNumber despite the fact that the listbox is displaying Descriptions (since you set the length of the 1st column = 0. If you set the bound column = 2, then the listbox will return description. Note that you can grab any column value from the list box by using
列表框将显示零件描述,但如果您将绑定列设置为 1,那么尽管列表框正在显示说明(因为您将第一列的长度设置为 0。如果您设置绑定列= 2,然后列表框将返回描述。请注意,您可以使用以下命令从列表框中获取任何列值
([lstBox1].Column)
([lstBox1].Column)
Note that in the above, the column feature is zero based. So, 1 = 2nd column
请注意,在上面,列特征是基于零的。所以,1 = 第二列
回答by paxdiablo
It's the column of the data set that is used to set the value of the listbox. For example, if it's bound to a dataset with the query:
它是用于设置列表框值的数据集列。例如,如果它通过查询绑定到数据集:
select firstname,lastname,userid from users;
then setting the bound column to userid (3 in the above example) will cause the user ID information to be returned as the listbox value.
然后将绑定列设置为 userid(上例中为 3)将导致用户 ID 信息作为列表框值返回。
回答by technoman23
A bound column is the data that the form is going to save. For instance, if you have a list box or combo box that lists employeeID and employeeName and you set the bound column to 0, the form will save the employee ID number from the selection and insert that value into the corresponding table. You can test which value you are referencing this using this vba:
绑定列是表单将要保存的数据。例如,如果您有一个列出employeeID 和employeeName 的列表框或组合框,并且您将绑定列设置为0,则表单将从选择中保存雇员ID 号并将该值插入到相应的表中。您可以使用此 vba 测试您正在引用的值:
Private Sub ComboBoxName_AfterUpdate()
MsgBox ("bound column is: " & Me.ComboBoxName.BoundColumn & ". value is: " & Me.ComboBoxName.Column(0))'change 0 to whatever number column is bound
End Sub
The bound column rule applies even if the first column is hidden on the form. For instance, the user could select "Mike Jones" from the employee list, but the form is going to save Mike Jones' employeeID for data uses (this ID could be stored in a table of sales records, etc.).
即使第一列隐藏在表单上,绑定列规则也适用。例如,用户可以从员工列表中选择“Mike Jones”,但表单将保存 Mike Jones 的员工 ID 以供数据使用(此 ID 可以存储在销售记录表等中)。