Reputation: 1129
In the below query I am trying to retrieve a set of records based on the value in the combo box control 'cboDepartments'. I am getting a syntax error message on the join function for the routine below but don't understand why.
sql_get = "SELECT * FROM ([tblValueChain01] INNER JOIN [tblTeams] ON [tblValueChain01].[Team] = [tblTeams].[ID]) INNER JOIN ([tblContacts] ON [tblValueChain01].[TeamLead] = [tblContacts].[ID]) WHERE ((([tblTeams].[Team])= '" & cboDepartments.Value & "'))"
Me.frmstaticdatadepartments07.Form.RecordSource = sql_get
Upvotes: 1
Views: 82
Reputation: 172378
In Access you have to use the parentheses when you have more than one join. Try this:
sql_get = "SELECT * FROM ([tblValueChain01]
INNER JOIN [tblTeams] ON [tblValueChain01].[Team] = [tblTeams].[ID])
INNER JOIN [tblContacts] ON [tblValueChain01].[TeamLead] = [tblContacts].[ID]
WHERE [tblTeams].[Team]= '" & cboDepartments.Value & "'"
Upvotes: 1