现在一切正常!谢谢大家的帮助
过去两个小时我一直在查看相同的代码行,并且不明白为什么我继续获得相同的运行时错误3067消息(查询的输入必须包含至少一个表/查询)。此查询假设将三个表与关系和过去的4列链接到第4个表。我直接从Access中构建的查询中复制了下面的代码..
DoCmd.SetWarnings False
st_sql = "INSERT INTO tblContactsProjectTrk01 ([Participant], [Sub_Project], [Role_type], [Completion_Percentage])" & _
"SELECT [tblProjManagementPhaseParticipants].[Participant], [tblProjectMasterList].[Sub project], [tblProjManagementPhaseParticipants].[Role_type], Avg([tblMasterListOfEvents].[Completion percentage]) AS MediaDiCompletion percentage" & _
"FROM[tblMasterListOfEvents] INNER JOIN ([tblProjManagementPhaseParticipants] INNER JOIN [tblProjectMasterList] ON [tblProjManagementPhaseParticipants].[ID_Project] = [tblProjectMasterList].[ID Project]) ON ([tblProjectMasterList].[ID Project] = [tblMasterListOfEvents].[ID Project]) AND ([tblMasterListOfEvents].[ID Event] = [tblProjManagementPhaseParticipants].[ID_Event])" & _
"GROUP BY([tblProjManagementPhaseParticipants].[Participant], [tblProjectMasterList].[Sub project], [tblProjManagementPhaseParticipants].[Role_type])" & _
"ORDER BY[tblProjManagementPhaseParticipants].[Participant]"
Application.DoCmd.RunSQL (st_sql)
答案 0 :(得分:1)
FROM之前没有空格,所以它实际上是percentageFROM。我认为应该是
...Avg([tblMasterListOfEvents].[Completion percentage]) AS [MediaDiCompletion percentage] " & _
"FROM[tblMasterListOfEvents]...
答案 1 :(得分:1)
在GROUP BY和ORDER BY语句之前,换行遇到了同样的问题。您需要在前一行和这两个语句之间留出空格。