如何在ComboBox下拉列表中隐藏列?
我正在Excel用户窗体中构建一个ComboBox,从Access表中获取其行。我想在下拉列表中向用户显示几个文本字段,但从ComboBox返回的值应该是与用户选择的行相关联的ID号(即ID列是绑定列)。但我不想向用户显示此ID号。有没有办法在ComboBox的下拉列表中隐藏列,但仍然有这个列被绑定?
I'm building a ComboBox in an Excel userform that gets its rows from an Access table. I want to display several text fields to the user in the dropdown, but the value returned from the ComboBox should be the ID number associated with the row that the user selects (i.e. the ID column is the bound column). But I don't want to show this ID number to the user. Is there a way to hide a column in the ComboBox's dropdown, but still have that column be bound?
如果你有三个列 - 第一个隐藏的ID,另外两个显示 - 在属性窗口中执行此操作:
If you have three columns - the first the ID that's hidden and the other two shown - do something like this in the Properties window:
请注意,Combobox1.Text将返回第2列中的文本(第一个可见一个)和Combobox1.Value将给你绑定列。 (ColumnHeads设置与上述无关)。
Note that Combobox1.Text will get return the text in the 2nd column (the first visible one) and Combobox1.Value will give you the bound column. (The ColumnHeads setting has no bearing on the above).