MS Access:在表单组合框中,列数> 1、如何显示结果表条目中的第2列?
我已经构建了一个简单的数据库,发布在此处(Access 2007 格式): http://www.derekbeck.com/Database1 .accdb
我有两个表:
- 一个任务列表
- 一个组织列表
我想要一个“分配组织”表单来从组织列表表中绘制一个下拉列表,我已经完成了。我将其设置为在下拉列表中显示几项内容:组织名称和组织类型。例如,下拉列表显示这两列:
airline | American Airlines
airline | United Airlines
eCommerce | ebay
eCommerce | Amazon
如果查看表“组织列表”,您会看到它是这样设置的:
ID org type org name website
1 airline American Airlines www.aa.com
2 airline United Airlines www.ual.com
我这样做两列数据的原因是因为该列表将是非常长,首先按组织类型排序,然后按字母顺序排序,这有助于数据输入。 (我用于此问题的目的的数据库和表格是假设的。)
因此,麻烦在于:当人们从表单上的下拉框中选择“分配组织”时,它基本上会逐步浏览“任务列表”表并允许基于“组织列表”的数据输入,正如我上面所说,您将得到以下内容:
airline | American Airlines
airline | United Airlines
eCommerce | ebay
eCommerce | Amazon
如果您选择第一行,则表单上的结果是“航空公司”。
* 我的第一个问题是:如何让它以填充形式呈现第二列(实际上是表格的第三列):也就是说,如何让它呈现“美国航空” ?
接下来,如果您转到“任务列表”的原始表视图,并查看新填充的“分配的组织”字段,您不会看到“航空公司”或“美国航空公司”,而是看到与其对应的 ID 号,例如上述情况中的“1”。
* 我的第二个问题:如何让它在表的原始数据字段中显示“美国航空公司”,而不是 ID 号?
最后,我读了一些关于关系的内容,并将“任务列表”表中的“组织分配”字段连接到“组织列表”表中的“组织名称”字段,但我不确定这是否正确。事实上,我不知道如何分配关系(如果有的话)。
* 最后一个问题:这里的关系如何解决这个问题?我需要它们吗?如果是的话我应该如何设置它们?
PS:我上面给出的表示例的确切顺序与我构建的示例数据库不匹配。
I have built a simple database posted here (Access 2007 format): http://www.derekbeck.com/Database1.accdb
I have two tables:
- a task list
- an organization list
I want a form "assign orgs" to have a dropdown list drawing from the org list table, which I have done. I have it set to show several things in the dropdown list: the org name and the org type. For example, the drop down list shows these two columns:
airline | American Airlines
airline | United Airlines
eCommerce | ebay
eCommerce | Amazon
if one looks in the table "org list" you'll see it set up this way:
ID org type org name website
1 airline American Airlines www.aa.com
2 airline United Airlines www.ual.com
The reason I am doing this two columns of data is because the list is going to be really long, and having them sorted by org type first than alphabetized second is helpful for data entry. (The database and tables I am using for the purposes of this question are hypothetical.)
So here's the trouble: when one selects from my dropdown box on my form "assign orgs", which basically steps through the "task list" table and allows data entry based on the "org list", you get, as I said above, the following:
airline | American Airlines
airline | United Airlines
eCommerce | ebay
eCommerce | Amazon
If you select, say, the first line, the result on the form is "airline".
* My first question is: how do I have it render in the populated form the second column shown (really the third column of the table): that is, how do I have it render "American Airlines"?
Next, if you go to the raw table view of "task list", and look at the newly populated "org assigned" field, you don't see "airline" nor "American Airlines" but the ID number corresponding to it, say "1" in the case above.
* My second question: how do I have it show "American Airlines" in the table's raw data field, not the ID number?
Finally, I've read a bit on relationships, and connected the "org assigned" field in the "task list" table to "org name" field in the "org list" table, but I'm not sure if this is correct. In fact, I'm not sure what to do, if anything, about assigning a relationship.
* Last question: how do relationships work for this problem here? Do I need them? How should I set them up if so?
PS: The exact order of the table examples I give above do not match the example database I built.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题 1 & 2
行源应包含 ID 和 orgName 作为输出,
将 Bound Column 属性设置为 1
将 Column widths 属性设置为 0cm;2.5cm
问题 3
任务列表表将/应该有一个名为 OrgId 的字段,它是组织表的外键。这就是关系的工作方式,在 TaskList 表单上应该有一个绑定到 OrgId 字段的组合框,其行源是具有上述属性的组织表。组合框向导将引导您完成设置,即使您已经有一个组合框,也可以放另一个组合框来逐步完成向导并查看属性。
Question 1 & 2
the row source should include both the ID and the orgName as outputs
set Bound Column property to 1
set Column widths property to 0cm;2.5cm
question 3
the task list table will/should have a field called OrgId that is a foreign key to the Organisation table. This is how relationships work, on the TaskList form there should be a combo box that is bound to the OrgId field, its row source is the Organisations table with the properties indicated above. The combo box wizard will step you through setting it up, even if you already have a combo box on there, put another one on to step through the wizard and look at the properties.