Access 2010-以表格形式显示相关记录 [英] Access 2010 - display related record in a form

查看:115
本文介绍了Access 2010-以表格形式显示相关记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个相关表. 发票(字段:编号,买方,供应商等)
公司-所有买家和供应商(字段:名称等)
发票上的买方"和供应商"字段引用了相同的字段(公司"表中的"company_id")

在发票表格上,我从下拉列表中选择供应商ID,也从下拉列表中选择买方ID.
任务:为了使表格更具可读性,我想在两个字段中选择公司ID后自动显示公司名称.
我做什么: 我手动将公司名称"字段拖到表单上,向导询问我要将其连接到哪个字段(byuer或供应商),因此我得到了1个字段.如何创建另一个显示公司名称的字段?如果我拖动公司名称的另一个实例,则向导不会显示,因此我可以对其进行设置,也无法在该位置找到任何设置.谢谢您的帮助.

I have 2 related tables. Invoice (fields: number, buyer, supplier, etc.)
Company - all buyers and suppliers (fields: name,etc.)
Buyer ans supplier fields on invoice are referencing same field (company_id from company table)

On invoice form, I choose supplier ID from dropdown list and also buyer ID from dropdown list.
Task: To make the form little bit readable, I would like to automatically display a name of company after selecting company id in both fields.
What I did: I manually dragged the company name field to the form and wizard asked me which field I would like it to connect to (byuer or supplier), so I got 1 field working. How to create another field that shows company name? If I drag another instance of company name, wizard does not show so I can set it up and I can not find anywhere setting for that. Thank you for help.

推荐答案

我认为最好的方法是:

  1. 创建查找查询:创建与此查询类似的新查询"SELECT CompanyId,CompanyName FROM t_Companies ORDER BY CompanyName;"并将其保存为"ql_Companies"

  1. Create a lookup query: Create a new query similar to this "SELECT CompanyId, CompanyName FROM t_Companies ORDER BY CompanyName;" and save it as "ql_Companies"

编辑您的发票表.对于买方"和供应商"这两个字段,请执行以下操作:单击该字段,然后在字段属性中选择查找".设置以下属性:更改显示控件=组合框,行源= ql_Companies,列数= 2,列宽= 0; 5,然后保存表格.

Edit your Invoice table. For both your fields Buyer and Supplier do the following: Click on the field and select Lookup in the filed properties. Set the following properties: Change Display Control = Combo Box, Row Source = ql_Companies, Column Count = 2, Column Width = 0;5 and save the table.

现在,当您基于发票表创建新表单时,该字段将自动显示为组合框.

Now when you create a new form based on your Invoice table the field will be automatically shown as a combobox.

您也可以在现有表单上手动完成所有这些操作,但是组合框将仅在此表单上显示.如果您使用查询查询准备基础表,那么它将自动在所有查询和表单中工作,而无需进行其他工作.

You can also do all this manually on an existing form but then the combo box will only show on this one form. If you prepare the underlying table with lookup queries then this will work in all queries and forms automatically without additional work.

这篇关于Access 2010-以表格形式显示相关记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆