access vba - Returning multiple values from a combo box reference -
i have combo box shows 2 bits of data, name , it's unique id number. have set there 2 columns displayed when user clicks on prior selecting record. trying source value in combo box use in update query. below string works fine source name (text) , make update cant source unique id number. have tried putting '.value in front put id not help.
this works fine update text value of control 'cboteams':
st_sql = "update tblstaticdatadepartments01 set tblstaticdatadepartments01.macroprocesso = [forms]![frmstaticdatadepartments01]![cboteams] (((tblstaticdatadepartments01.macroprocesso)is null))"
application.docmd.runsql (st_sql)
this not work when trying retrieve numerical value:
st_sql = "update tblstaticdatadepartments01 set tblstaticdatadepartments01.idmacroprocesso = [forms]![frmstaticdatadepartments01]![cboteams].[value] (((tblstaticdatadepartments01.macroprocesso)is null))"
application.docmd.runsql (st_sql)
it sounds combo box has 2 columns, this:
with column count set 2:
and bound column set 2nd column (or whatever column has text value):
when use .value
, value of bound column only. value of different column, can use .itemdata(colnum)
, this:
st_sql = "update tblstaticdatadepartments01 set tblstaticdatadepartments01.idmacroprocesso = " & forms("frmstaticdatadepartments01").cboteams.itemdata(0) & " (((tblstaticdatadepartments01.macroprocesso) null))"
the columns zero-based, retrieve first column use itemdata(0)
, second column use itemdata(1)
, , on. kind of confusing because property page of "column count" setting 1-based.
microsoft's examples make can use itemdata function using expression syntax this, did not work me in copy of access 2003. however, code gave should work fine.
st_sql = "update tblstaticdatadepartments01 set tblstaticdatadepartments01.idmacroprocesso = [forms]![frmstaticdatadepartments01]![cboteams].[itemdata](0) (((tblstaticdatadepartments01.macroprocesso) null))"
you can retrieve value of column , row (not selected row) using column function, in case ever have need. see https://msdn.microsoft.com/en-us/library/office/ff192660.aspx
Comments
Post a Comment