我正在编写以下代码来填充Combobox。
strSQL = "Select BankID, BankName As [Please Select Bank] from tblBank"
With Me.cmbBank
.RowSource = strSQL
.ColumnCount = 2
.BoundColumn = 2
.ColumnWidths = "0in.;1in."
.ColumnHeads = True
.LimitToList = True
.Requery
.Value = "Please Select Bank"
End With
在Button CLick上,我正在检查组合框选择的值,代码就在这里。
MsgBox Me.cmbBank.Value
它显示文本,有没有办法获得选定值(BankID)?
答案 0 :(得分:1)
将此值更改为BankID的有效值:
.Value = "Please Select Bank"
或您的组合返回 Null 会导致MsgBox失败,或者使用 Nz 更正
MsgBox Nz(Me!cmbBank.Value, "No bank selected.")
答案 1 :(得分:0)
Get