简体   繁体   English

MS Access:用来自单独表的数据填充子窗体字段组合框吗?

[英]MS Access: Making a subform field combo box populate with data from separate table?

I'm trying to convert a form previously made in an old Excel to something that can be used in current versions of Access. 我正在尝试将以前在旧Excel中制作的表单转换为可在当前版本的Access中使用的表单。 The Excel version has a feature where values put in a field in one table can be referenced to be used as values in another table. Excel版本具有一项功能,其中可以引用放在一个表中的字段中的值以用作另一表中的值。 Ex: 例如:

Table A: Name Field has values {Joe, John, Lisa, Mary, Max} 表A:“名称”字段的值为{Joe,John,Lisa,Mary,Max}

Table B: Click on name field, values to choose from {Joe, John, Lisa, Mary, Max} 表B:点击“名称”字段,然后从{Joe,John,Lisa,Mary,Max}中选择值

I'm attempting to replicate this in MS Access with subforms connected to tables. 我正在尝试使用连接到表的子窗体在MS Access中复制它。 My current set-up is: 我当前的设置是:

Table A: Name Field has values {Joe, John, Lisa, Mary, Max} 表A:“名称”字段的值为{Joe,John,Lisa,Mary,Max}

Table B: Name field connected via Lookup Wizard to Name Field in Table A 表B:通过查找向导连接到表A中的名称字段的名称字段

Subform: Table B displayed in subform. 子窗体:以子窗体显示的表B。 Name field of Table B is a combo box. 表B的名称字段是一个组合框。

I want the combo box to drop down containing the contents of Table A's Name field. 我希望下拉框包含表A的“名称”字段的内容。 However, when I click on that combo box, I simply get an error noise and nothing happens. 但是,当我单击该组合框时,我只是得到一个错误提示,什么也没有发生。

I haven't attempted any coding, as I'm not well versed in VBA, so there may be a better way. 我没有尝试任何编码,因为我对VBA并不熟悉,所以可能有更好的方法。

If this isn't enough information, I'll try to provide more. 如果这还不够,我将尝试提供更多信息。

  1. Create a MS Access query of the field containing the values in table A (should look like this "Select Field from TableA;"). 创建一个包含表A中的值的字段的MS Access查询(应类似于“从TableA中选择字段;”。)。
  2. Copy the query SQL and paste SQL string into the combobox property "Row Source". 复制查询SQL并将SQL字符串粘贴到组合框属性“行源”中。
  3. Set the combobox property "Row Source Type" to "Table/Query". 将组合框属性“行源类型”设置为“表/查询”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM