Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a ComboBox which loads a country list, every time i select one item and then focus in other object of the form it resets to 0. This ComboBox is linked with an Integer value in the main table (it stores the index, not the string of the country).

What the heck am I doing wrong?

share|improve this question

If I understand you correctly, you want a ComboBox that displays a list of country names and stores some sort of country code. You can use a ComboBox to display and store a field, but not to display one field and store another. Unlike the ListBox control, the ComboBox does not have a Bound Field property, which is required to use two fields. The Bound Field property determines what field is stored in your target table.

enter image description here

You need to use a ListBox control to get this functionality. The ListBox control should give you a wizard. First select the table the you want to display data from.

enter image description here

Then select the field you want to display.

enter image description here

Lastly, select the field you want to store the value to (left-side list) and the field you want to get the value from (right-side list). NOTE: In this example, I am only using one table. So I have the same options in both the left-side and right-side lists. Normally, you would pull this data from another table to be displayed and stored in the current - usually as some sort of foreign key relationship.

enter image description here

Then we need to make the ListBox act like a ComboBox, that is, make the ListBox have a dropdown menu. Right-click the ListBox and go to Control. Set the DropDown property to Yes. Set the LineCount to however many items you want displayed without needing to scroll (I like 5, personally). Lastly, set the Height to something more like what a Text field would be.

enter image description here enter image description here


share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .