如何在 VBA -MS Access 中获取绑定列值

How to get bound column value in VBA -MS Access

我的 form 中有一个 combo box,我从另一个 table role.
中填充了它 role 有两列:IdRole
鉴于我的 table 在 Row SourceBound Column 中的值为 2 并且 column widths0cm;2cm

我可以在组合框中看到我的 Role,这很好。我需要的是

  1. Submit 上,我想读取 VBA 中所选 RoleId 值。如何实现这个 -- 通过将绑定列值设置为 1
  2. 解决了这个问题
  3. 如何将默认值设置为 Role -- 帮助实现这一点

我必须以相同的形式为我的 ListBox 设置类似的大小写

因为你有一个多列组合框,所以两个问题都与同一个组合框有关属性:column

MyComboBox.Column(Index, Row)

行是可选的。

Use 0 to refer to the first column, 1 to refer to the second column, and so on. Use 0 to refer to the first row, 1 to refer to the second row, and so on.

问题一:假设你绑定了你的id到第二列。在提交代码中,您可以像这样检索您的 ID:myid = MyComboBox.Column(1)

问题2:假设你想分配role id = 3并且你的id绑定到第2列。在你的表单的Load事件中,做这:MyComboBox.Column(1) = 3