MS Access Dropdown List/Combo Box

后端 未结 4 1864
执笔经年
执笔经年 2021-01-21 13:24

This should probably be pretty simple but my Google-Fu is as yet unable to find an answer. I simply want to create a dropdown list in Access so that upon selection I can perform

相关标签:
4条回答
  • 2021-01-21 13:55

    You will need to hook into the onchange event for the dropdown list.

    and from MSDN

    0 讨论(0)
  • 2021-01-21 13:58

    OK, I figured it out even though it was a bit counter-intuitive. An Access Combobox can have as many values as you want (instead of just one key on value). By default all of the values are are shown in the list so you need to hide certain columns by setting their widths to 0. That is done via the ColumnsWidths property in the property pane. ColumnWidths takes a comma separated list of values which corresponds to the order of the columns in the list. I hope this helps someone.

    0 讨论(0)
  • 2021-01-21 13:59

    How have you set the properties for your combo box?

    Perhaps you could try setting (assuming you are pulling data from Table1 with fields ID and Field1

    • Row Source: SELECT [Table1].[ID], [Table1].[Field1] FROM Table1;
    • Row Source Type: Table/Query
    • Bound Column: 1
    • Column Count: 2
    • Column Widths: 0", 1"

    and then hook into the onchange event as Chris Ballance suggests. The value property of the combo box is ID; the text will be what is in Field1.

    0 讨论(0)
  • 2021-01-21 14:06

    It sounds like you might be asking how to display something in the dropdown other than the ID while keeping the ID as the returned data from the dropdown. If that's the case set the Bound Column to the ID field (usually 1) and (assuming the name field is next) set the Column Count to be 2 and the Column Widths to be 0";1" or 0";[whatever width you need].

    0 讨论(0)
提交回复
热议问题