Allen Browne的ConcatRelated()错误3061:参数太少

问题描述 投票:1回答:1

我正在尝试在给定仓库中创建产品列表。 Allen Browne的ConcatRelated()函数似乎是在链接变量相同时创建列表的尝试和真实方法,但我无法使其工作。

我已将我的信息分解为单个查询...“qry_Products”

SELECT qry_AX_LineItems_LINES.Warehouse, tblREF_Chemical.[Sales Name]
FROM qry_AX_LineItems_LINES INNER JOIN tblREF_Chemical ON 
qry_AX_LineItems_LINES.ItemId = tblREF_Chemical.[Item Number]
GROUP BY qry_AX_LineItems_LINES.Warehouse, tblREF_Chemical.[Sales Name];

它生成一个包含销售名称和仓库的表。

我需要看到的是仓库匹配时的销售名称列表。

我试过在我的表单的文本框中使用该函数...

=ConcatRelated("[Sales Name]","[qry_Products]"," Warehouse ='" & [Warehouse] 
& "'")

它会导致错误3061并将单元格留空。

我使用Dlookup()在引号中仔细检查了我的语法,它产生了列表的第一个结果。

我也尝试改变我的查询......

SELECT qry_AX_LineItems_LINES.Warehouse, ConcatRelated("[Sales Name]"," 
[tblREF_Chemical]") AS Expr1
FROM qry_AX_LineItems_LINES INNER JOIN tblREF_Chemical ON 
qry_AX_LineItems_LINES.ItemId = tblREF_Chemical.[Item Number];

不幸的是,它然后将我数据库中的每个产品列为列表。

我还尝试创建一个新的查询来引用产生最少信息的查询。

SELECT ConcatRelated("[Sales Name]","qry_Products") AS Expr1
FROM qry_Products;

我知道初始查询是正确的,但是当我去运行新查询时,我得到多个错误3061的弹出窗口并且结果为空单元格。

我仔细检查了我是否正在复制模块。 http://allenbrowne.com/func-concat.html模块被命名为“Concat”。

我正在阅读那里的每一个帮助指南,但我看不出接下来应该尝试什么。

非常感谢您的时间和建议!

SubForm frm_LineItems

Query qry_Products

sql concatenation ms-access-2016
1个回答
0
投票

我发现另一个线程可以替代Allen Browne方法。 https://bytes.com/topic/access/answers/569535-combining-rows-opposite-union

这似乎有效。

'Concat Returns lists of items which are within a grouped field
Public Function Concat(strGroup As String, strItem As String) As String
Static strLastGroup As String
Static strItems As String

If strGroup = strLastGroup Then
    strItems = strItems & ", " & strItem
Else
    strLastGroup = strGroup
    strItems = strItem
End If
Concat = strItems
End Function

使用Query SQL

SELECT WH,
Max(Concat(WH, [Sales Name])) AS Products
FROM [qry_Products]
GROUP BY WH

我想留下这个以防万一其他人有类似的问题。

© www.soinside.com 2019 - 2024. All rights reserved.