假设,vba代码具有
Dim SQL as String
SQL ="select * from table"
我找到了有助于将相关行中的值组合成单个串联字符串值的函数,但是当我实现我的代码时,该函数不起作用,因为查询中的双引号会产生错误,这是使语法有效的最佳格式在vba中。该函数在下面给出,链接为(Combine values from related rows into a single concatenated string value)。
SELECT
i.N_ID,
i.F_Name,
i.L_Name,
ConcatRelated(
"Course_ID",
"tbl_Courses",
"N_ID = '" & [N_ID] & "'"
) AS Course_IDs
FROM tbl_Instructors AS i;
答案 0 :(得分:0)
您的ID很可能是数字而不是文本,因此没有单引号:
SELECT
i.N_ID,
i.F_Name,
i.L_Name,
ConcatRelated(
"Course_ID",
"tbl_Courses",
"N_ID = " & [N_ID] & ""
) AS Course_IDs
FROM tbl_Instructors AS i;