我有一个组合框,想要将其值与SQL WHERE子句一起使用。如何基于组合框值在VBA中 运行 SELECT语句?
如果您希望使用绑定列的值,则可以简单地参考以下组合:
sSQL = "SELECT * FROM MyTable WHERE ID = " & Me.MyCombo
您还可以参考column属性:
sSQL = "SELECT * FROM MyTable WHERE AText = '" & Me.MyCombo.Column(1) & "'" Dim rs As DAO.Recordset Set rs = CurrentDB.OpenRecordset(sSQL) strText = rs!AText strText = rs.Fields(1)
在文本框中:
= DlookUp("AText","MyTable","ID=" & MyCombo)
*编辑