Display the corresponding 'unbound' column entry of a combobox

Mist

Registered User.
Local time
Today, 23:06
Joined
Mar 5, 2012
Messages
66
Is there a simpler way to display the corresponding 'unbound' column entry of a combobox when the 'bound' column entry is selected? - or am I missing something?

I have a form with a 2-column combobox populated from its own table of about 16 records. It updates a 1-digit text field on this form with an alpha character (bound column -1). Works fine.

I created a listbox to display the other associated column (corresponding
'unbound' entry) to describe what the single alpha digit represents (much like the State Abbreviation-Name scenario).

I defined the row source* in the list box properties which works when I switch to its datasheet view or run it, but showed all 3 combobox selections, 1 for each of 3 records currently in the main table.

I put in a criteria entry to display only the contents relating to the selected alpha character the datasheet view displays one blank record (instead of the anticipated 1-line description, but on returning to the form the listbox displays correctly but doesn't change to the next corresponding description when next-record, >, is selected. The description remains the same fo all records (only 3 at present) and sometimes does't show at all until the form is closed and
reopened

I have also attached a Me.listbox.requery to the 'after update' property of the combobox (as well as the form's 'on load' property)

* SELECT NoPemp.NoPtype, Common.NoP
FROM NoPemp INNER JOIN Common ON NoPemp.NoPID = Common.NoP
WHERE (((Common.NoP)=[forms]![common f1].[CmbNoP]));
 
If your combo box has two columns and you want to show the first column as selected from the combo box and then have the value from the second column of your combo box to be displayed you do not need a list box.

Put a text box on your form. With this text box selected, select the Data tab from the Properties pane. In the "Control Source" property type:
Code:
=[NameOfYourComboBox].column(1)

Open your form in form view and you should see the second column of your combo box displayed in the unbound text box. You can then set the "Locked" property of the text box control to "Yes" and uses will be able to see the value but not changes it.

The columns of a combo box or list box use a zero based numbering, therefore, the first column is numbered zero and the second column is numbered 1.
 
If you want to display the second column in the combo box after selection, set the following properties to the combo box:

  • In Data:
    • Make sure the correct columns are used as row source (e.g. 'ID' and 'Name', in that order)
    • Set Bound Column to '1'
  • In Format:
    • Set Column Count to '2'
    • Set Column Widths to '0;2cm' (or anything similar)
Now only the second column will be shown, and you can set the value by the first column.
 

Users who are viewing this thread

Back
Top Bottom