简体   繁体   English

MS访问控制源DLookUp

[英]MS Access Control Source DLookUp

I haven't been able to make a DLookUp function work in an Access report. 我无法在Access报告中使DLookUp函数正常工作。 I can't figure out what I'm doing wrong. 我不知道我在做什么错。

The report is getting its dataset from a query called Aggregate Query. 该报告是从称为“聚合查询”的查询中获取其数据集的。 This query builds a dataset from 20 related tables using CustomerID as the primary key in one table and as a foreign key in the other 19. CustomerID is specified by an open Form with the desired customer's record displayed, including the CustomerID field. 该查询从20个相关的表中构建数据集,并使用CustomerID作为一个表中的主键,作为另一个19中的外键。CustomerID由打开的表单指定,并显示所需的客户记录,包括CustomerID字段。

This means Aggregate Query has several rows for one specific CustomerID. 这意味着聚合查询针对一个特定的CustomerID有几行。 One field, Needs Notes, will have the same content on every row. “需求记录”字段将在每一行具有相同的内容。 What I'm having trouble with is getting only one of these rows displayed in the subreport, and subsequently on the parent report. 我遇到的麻烦是只能在子报表中显示这些行之一,然后在父报表中显示。

If there are six rows, say, in Aggregate Query, then the same Needs Notes field is repeated six times. 例如,如果有六行,则在“聚合查询”中,相同的“需求记录”字段将重复六次。 I want it to appear only once in the subreport. 我希望它在子报表中仅出现一次。

I couldn't choose only the first row from Aggregate Query. 我无法从“聚合查询”中仅选择第一行。 If this can be done that'd be great. 如果可以做到,那就太好了。 I don't know. 我不知道。

So I created another query, Need-notes Only Query, which always gives me only one row every time. 因此,我创建了另一个查询,“仅需注意的查询”,每次始终只给我一行。 So far so good. 到现在为止还挺好。 Now I want the contents of the Needs Notes field to appear all by itself in the subreport. 现在,我希望“需求注释”字段的内容单独出现在子报表中。 To do this I selected the text box and entered the following into the Control Source parameter: 为此,我选择了文本框,然后在“控件源”参数中输入了以下内容:

=DLookUp("[Needs-notes Only Query]![Needs Notes]","Needs-notes Only Query")

No dice. 没有骰子。 I get six rows saying #Error. 我得到六行说#Error。

Is there a way I can get just one row of the Needs Notes field into my report? 有什么办法可以使我的报告中的“需求记录”字段仅占一行?

拆分字段和表名称:

=DLookUp("[Needs Notes]","[Needs-notes Only Query]")

I have found a work-around. 我找到了一种解决方法。 Thank you for your comments. 谢谢您的意见。

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

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