Value in a Combo Box as a Variable

S

SharonInGa

How do I take the value from a Combo Box and turn it into a variable so I can
update a table in a SQL database?
 
K

Ken Snell [MVP]

Concatenate its value into an SQL string that you build in code.

or

Write a public function that reads the value in the combo box and returns it
as the value of the function; call this function from a query (assumes that
you're running the query in the ACCESS front end).
 
K

Ken Snell [MVP]

For numeric fields:
strSQL = "SELECT * FROM MyTable WHERE [FieldName]=" & Me.ComboboxName.Value


For text fields:
strSQL = "SELECT * FROM MyTable WHERE [FieldName]='" & Me.ComboboxName.Value
& "'"

--

Ken Snell
<MS ACCESS MVP>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Combo box 0
Combo or list box 0
Undo a combo box selection 3
Combo or list box 0
Combo Box On Click 8
Combo Box case sensitivity 0
Drop down list control value in vba 2
Update Combo Box 4

Top