bgm*_*der 2 ms-access vba combobox
在我的访问表单上,我有一个空组合框,其Row Source Type设置为Table/Query,绑定列设置为1。
我想要做的是通过代码,用两列填充此组合框,其中向用户显示第一列,然后在代码中我将从第二列中获取值。
我的问题是,如何填写这些列?Row/Source我知道如果设置为Value List- 但这只是一个平面列表;如何填充组合框;我想要这里有两列。
我无法对列数据使用单独的查询/表,因为我正在动态生成它。基本上,我用编辑字段控件名称及其标题的列表填充组合框。用户从组合框中选择标题名称,然后我可以获取控件名称。
我只需要知道如何将数据添加到组合框中的列。
所以,我想了这样的事情(我知道这是不正确的,但你可以看到我想要完成的事情):
Me.mycombobox.AddItem("column 1 data";"column2 data")
Run Code Online (Sandbox Code Playgroud)
If you add this into to your event that will trigger the combobox being filled it should shed some light on your question:
Me.Combo0.RowSource = "Row1Column1;Row1Column2;Row2Column1;Row2Column2"
Run Code Online (Sandbox Code Playgroud)
Make sure that your Column Count is set to 2 for this example. Basically you will just build a string formatted like the one in the example filled with the contents that you want to be filled into the combobox. Then just assign it to your Combobox's RowSource.
Basically when you input 6 items as the RowSource:
Item1, Item2, Item3, Item4, Item5, Item6
Run Code Online (Sandbox Code Playgroud)
It will shift based on what you have the Column Count is set to, for example if the column count is set to 3, the above list will turn into:
Item1 Item2 Item3
Item4 Item5 Item6
Run Code Online (Sandbox Code Playgroud)
If the column count is set to 2 then it will turn into:
Item1 Item2
Item3 Item4
Item5 Item6
Run Code Online (Sandbox Code Playgroud)
Note: Make sure that you set the Row Source Type to "Value List".
| 归档时间: |
|
| 查看次数: |
8396 次 |
| 最近记录: |