简体   繁体   English

在ms访问中记录源和控制源

[英]Record source and control source in ms access

I am creating a continuous form in MS Access 2010. In the details section of the form, I have two text boxes (named txtProj and txtArtifact). 我正在MS Access 2010中创建一个连续表单。在表单的详细信息部分中,我有两个文本框(名为txtProj和txtArtifact)。

There are 2 tables in the database. 数据库中有2个表。 tblProject and tblArtifact. tblProject和tblArtifact。

tblProject has [Project ID] - autonumber and [Project Name] - string.
tblArtifact has [Artifact ID] - autonumber, [Project] - number and [Artifact Name] - string. 

[Project ID] and [Project] are related by one-to-many relationship. [Project ID][Project]通过一对多关系关联。

The Record Source for the form is tblArtifact. 表单的记录源是tblArtifact。 Now, in the textbox named txtProject, I want to display name of the project, rather than Project ID. 现在,在名为txtProject的文本框中,我想显示项目的名称,而不是项目ID。

I am not able to figure out, how to refer to a control source of a table, which is not record source of the form. 我无法弄清楚如何引用表的控件源,而该表不是表格的记录源。

Please help me. 请帮我。

I would be happy to provide any additional details, if required. 如果需要,我很乐意提供其他详细信息。

Thanks in anticipation. 谢谢您的期待。

Try it by joining the two tables, 通过连接两个表来尝试一下,

SELECT  b.[Artifact Name]
FROM    tblProject a
        INNER JOIN tblArtifact b
            ON a.[ProjectID] = b.[Project]
WHERE   b.Project = 'value'

All that was required to be done was this: 所需要做的就是:

  1. Set record source property of the form as: 将表单的记录源属性设置为:
SELECT
    tblProject.*,
    tblArtifact.*
FROM tblProject INNER JOIN tblArtifact ON
    tblProject.[Project ID] = tblArtifact.Project;
  1. Now the control source property gets additional drop down options where [Project Name] is included. 现在,控件源属性获得了附加的下拉选项,其中包含了[Project Name] Select that. 选择那个。

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

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