【发布时间】:2010-06-29 20:21:20
【问题描述】:
我有一个表 tblInvestigators,其中包含一个查找字段以显示名称列表
一项资助可能有超过 1 名调查员。
我的项目的一个要求是在拨款详细信息旁边的一个单元格中列出所有研究人员,所以我有:
赠款 A |姓名 A、姓名 B、姓名 C 等等
我有一个 VBA 模块,将调查人员连接到 1 个单元格中,如下所示:
'Concat Returns lists of items which are within a grouped field
Public Function c(strID As String, strAddMe As String) As String
Static prevID As String
Static strFinal As String
Static strLastAdded As String
If (strID = prevID And strAddMe <> strLastAdded) Then
strFinal = strFinal & ", " & strAddMe
Else
prevID = strID
strLastAdded = strAddMe
strFinal = strAddMe
End If
c = strFinal
End Function
以及调用它的访问查询(SQL):
SELECT g.grant_id, Max(c(g.grant_id,tblInvestigators.investigator)) AS Expr1
FROM tblGrants AS g LEFT JOIN tblInvestigators ON g.grant_id = tblInvestigators.grant_id
WHERE (((g.grant_id)=6))
GROUP BY g.grant_id;
当我运行它时,它返回一个逗号分隔的列表,但它是查找列 (tblInvestigators.investigator) 中的 ID 号列表,而不是名称。我怎样才能得到名字?
克里斯
【问题讨论】:
标签: ms-access module field lookup