1

All Works fine now! Thank you all for your help

I have been looking at the same line of code for the last two hours and don't understand why I continue to get the same Run Time Error 3067 message (input for the query must contain at least one table/query). This query is suppose to take three tables, linked with relationships and past 4 columns to a 4th table. The code below I copied directly from a query built in Access which worked..

 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)

2 Answers 2

2

There is no space before the FROM, so it is actually percentageFROM. I think it should be

...Avg([tblMasterListOfEvents].[Completion percentage]) AS [MediaDiCompletion percentage] " & _
"FROM[tblMasterListOfEvents]...
Sign up to request clarification or add additional context in comments.

3 Comments

Fantastic! Thank you ... Now however the new message is run time error 3075... missing operator...??
I'd suggest going back to Access and creating your query again using the visual designer then switching to SQL view and copying that into your VBA code. You just need to make sure you include all the spaces
Crazy Horse, i re-did everything and copied and pasted the SQL code from the Access query which worked but i am still getting the 3075 message telling me i am missing an operator
1

You have the same problem with your line wrapping before your GROUP BY and ORDER BY statements. You need spaces between the previous line and those two statements.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.