Problem with combo box, have 2 bound columns, only seeing one in box.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ncsthbell
    New Member
    • May 2007
    • 167

    Problem with combo box, have 2 bound columns, only seeing one in box.

    Using MS Access 2007.
    I have a combo box that is defined with 2 columns. A file sequence number and file name. When you click the down arrow in the combo box, you see both columns. However, when selecting a row from the list, only the file sequence number shows in the combo box. In the code when I look at "cmbFileInfo.va lue", the value is the file name. I am very confused on why I don't see both values when I select the row in the combo box. I believe I have all the properties set correctly but I may be missing something.

    On the properties I have:column count = 2
    bound columns = 2
    column width = 0.5;3"
    column heads = no
    limit to list = yes
    allow value list edits = no
    inherit value lists = yes
    show only row source values = no
    enabled = yes
    locked = no
    auto expand = yes
  • MikeTheBike
    Recognized Expert Contributor
    • Jun 2007
    • 640

    #2
    Hi

    The 'visible' field in the list box is the left most field that is visible, ie with a column with width greater than zero.

    The value returned by the ComboBox is always from the 'Bound' column.

    If you want more than one field to be visible in the list after selection (as opposed to the dropped down list), then the fields required will need concatenating together as one field in the query that is assigned to the ComboBox 'Row Source'. This is then displayed as one field, and would not normally be the bound coulmn. In this case the bound column is often hidden (zero column width).

    Hope that makes sense!

    MTB

    Comment

    • ncsthbell
      New Member
      • May 2007
      • 167

      #3
      Maybe combo box is not the way I need to go. I do not want to have to worry about parsing 2 values from one string, especially when I don't know what the size may be. Would using a listbox be better?

      Comment

      • MikeTheBike
        Recognized Expert Contributor
        • Jun 2007
        • 640

        #4
        If you want to display multilpe columns before and after selection then a list box might be better. if you want to use multiple selection then it is the only option. It depends on what you are trying to do.

        I'm not sure why you would need to parse a field, as you can have any field you like (you can have a specific field both concatenated and/or on its owm) in the ComboBox list records, and have them hidden if they are not relevant to the user.

        You can then access the required field of the selected item in the list by using the ComboBox.Column (ColumnIndex) propery to capture any of the fiields values, visible or otherwise.

        MTB

        Comment

        Working...