Bound Column Property

  • Thread starter Thread starter Doug V
  • Start date Start date
D

Doug V

My combo box has two fields that I grab, can I bind the column to both
values.

It seems I can only do one.

Please assist.
 
Someone will correct me if I'll wrong but I believe you
can only bind one.

Hope that helps (though probably not what you wanted to
hear)
 
In general the left field will be an ID with zero width. The second from
left column will be the first displayed. Multiple columns can be displayed
in the drop-down box. However, only one selection is possible, which
becomae the cbo value after the selection is made. Th display additional
fields use additional textboxes with the control property
=me!cboBox.column(*); in place of * put a number 1, 2, 3, etc. for the
specific column from L to R that you want displayed. When the CboBox
selection is changed, the texbox contents will also change.

See Access Help for the column property for examples.
 
My combo box has two fields that I grab, can I bind the column to both
values.

It seems I can only do one.

You can only bind one column to an underlying field - the column you bind should
be the column that contains only unique values (each value is present in only
one row in the list so that there are no duplicates). If you need to display a
value in another column in the combo box from the selected row, you can set the
"Control Source" of a new text box to something like this:

=[ComboboxName].Column(1)

This would display the value in the *second* column of the selected record. At
runtime, combobox and listbox columns are "zero-indexed" - that means that the
first column is Column(0), the second column is Column(1), etc.. You can also
display multiple column values at once by concatenating the values together:

=[ComboboxName].Column(2) & ", " & [ComboboxName].Column(1)

If you simply want to retrieve a value from another column in your combo box,
you can use the same referencing method:

MyValue = [ComboboxName].Column(1) 'Second column's value

Lastly, if you are trying to *fill* two fields with values from two separate
columns in the combo box, the recommendation is to NOT store the second value.
If your second value can be determined from the first value in the combo box's
list, then that value can always be looked-up to eliminate storing redundant
data.
 
Just a reminder (since it causes problems for a lot of users until they
figure it out). Column numbering starts at 0, not 1.
 
If you are asking how to display the values in both fields, you can't directly.
You can only display the value in one column of your rowsource; which one is
determined by the order of the columnsfrom left to right in your rowsource, the
column count property and the column widths property.

You can however combine data into one column and then display the combined data.
Suppose you want to display Customer names and addresses in your combobox. You
need to create a query. Put the CustomerID in the first column of the query and
then the following expression in the second column:
=[CustomerName] & " " & [Address] & " " & [City] & ", " & [State] & " " &
[Zip]

Your combobox will then display customer records like:
Joe's Hardware 212 South St. Clarion, PA 16214
 
Back
Top