I'm trying to attach a SELECT query to a VBA object in Access, but I keep getting the error:
Syntax Error in Join operation
Dim sql As String
sql = "SELECT R_History.iteration, R.RuntimeID, Policylanguage.FormBody " & _
"FROM PolicyLanguage " & _
"INNER JOIN ([Policy&Elements] " & _
"INNER JOIN ((R " & _
"INNER JOIN R_History " & _
"ON (R.RunTimeID = R_History.RunTimeID " & _
"AND (R.ReportID = R_History.ReportID)) " & _
"INNER JOIN StatePolicyLanguage " & _
"ON R_History.Iteration = StatePolicyLanguage.Iteration) " & _
"ON [Policy&Elements].[Text&ElementID] = StatePolicyLanguage.[TextID&ElementID] " & _
"ON PolicyLanguage.TextID = [Policy&Elements].TextID " & _
"WHERE (((R.RuntimeID) = Dlast('runtimeID','r')));"
DoCmd.RunSQL (sql)
I can't get this to run for the absolute life of me. Can anyone tell what's wrong?

ONstatements there without parentheses between them. You're missing some parentheses. Also, writing eachONstatement after the corresponding join, like @apomene said, is a good plan (though it's not required, you can first write all the joins and then all the on clauses and group them using parentheses, but that results in illegible code, like you have now). - Erik ADoCmd.RunSQLis used for action queries no resultset queries. Please advise what you are trying to do: Open recordset? Update form/report recordsource? And why are you not saving the query (more efficient than a VBA string query as engine can compile it with best execution plan including indexes)? - Parfaitvar1=me.field1,var2=me.field2(where both vars arestring), and then concatenate those into the query-- but that isn't the issue in my particular question. - VBAmazing