Multi-column combo box parameter

  • Thread starter Thread starter Emma
  • Start date Start date
E

Emma

Is there a way to use a single column in a multi-column
combo box as a parameter for a query? I've tried using
the control.column(0) and am not having any success.
 
Yes,

But it would be helpful to have a little more information.

Column(0) is the first column in the combo box, and is
usually the bound column. If you want to use the bound
column, you don't even have to use the .column() syntax,
as this is the default. If you want to use some other
column, then you can create at query that references the
other column like:

SELECT * FROM yourTable
WHERE yourTable.SomeField = Forms!frm_YourForm!
cbo_SomeCombo.column(1)

HTH
Dale
 
If I recall correctly, referencing a column of a combobox or listbox doesn't
work in a query. You can use a function to get the value or if you want to use
the bound column you just reference the control.

UNTESTED AIRCODE to get the value of a column

Public Function fGetColumn (CtlAny as Control, intColumn as integer)

fGetColumn = CtlAny.Column(intColumn)

End Function

Select ...
FROM ...
WHERE FieldA = fGetColumn(Forms!YourFormName!YourControl,0)
 
Back
Top