how to write the sql code to get selected combo box value

  • Thread starter Thread starter Ramburst
  • Start date Start date
R

Ramburst

Hai guys,

I'm writing a SQL code in MS Access to store the value
selected in the form from a combo box. The value I want is
in the 2nd column of the combo box.

docmd.runsql "INSERT logcall (customers)
VALUES (cbocustomers.column(2));"

but once i ran the code it return error of "undefine
function". However when I typed:
Msgbox cbocustomers.column(2) it return the value of 2nd
column I selected in the combo box correctly.

How does SQL read the value based on the combo box and
it's column I selected. If I use 'cbocustomer' and
not 'cbocustomer.column.2' I abled to get the 1st column
value of the combo box which is not I want.

Thanks for reading and be greatful if I got any reply...
(Hey Reggie sorry to trouble u again..hhe)
Ram.
 
if the value in cbocustomers.column(2) is numeric, try
docmd.runsql "INSERT logcall (customers)
VALUES (" & cbocustomers.column(2)& ");"

if the value in cbocustomers.column(2) is text, try
docmd.runsql "INSERT logcall (customers)
VALUES ('" & cbocustomers.column(2)& "');"

hth
 
Hello,

I'm not sure why you are writing SQL code to do this. Why not just go into the Properties of the Combo Box, and change the "Bound Column" property to 2?

Bob Sullivan
 
Back
Top