简体   繁体   中英

MS Access Control Source DLookUp

I haven't been able to make a DLookUp function work in an Access report. 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.

This means Aggregate Query has several rows for one specific 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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