Hi, could someone point me in the direction of some resource for the proper syntax of including, say, the output from a combobox into an sql string in vba?
Hi, could someone point me in the direction of some resource for the proper syntax of including, say, the output from a combobox into an sql string in vba?
Hi, could someone point me in the direction of some resource for the proper syntax of including, say, the output from a combobox into an sql string in vba?
First, a ComboBox has no "output". It has properties that you can use in SQL queries based on the selection in the ComboBox. Most of the time, you want to use the Value property, which contains the value of the first column of the selected record of the Rowsource. Sometimes you rather need the value of another column. You can access that with the indexed Column property.
Building a SQL string with the numeric value of a ComboBox in the form of the control would look like this in code:
Code:
strSQL = "SELECT SomeColumns FROM yourTable WHERE aColumn= " & Me.yourComboBox.Value
Please see my extensive tutorial on SQL strings building in VBA for further reference.
The link to MSDN, provided by Beetle, is quite good as well, but it lacks essential information for Non-US environments.