The below retreive query works fine until i insert the WHERE clause which is linked to a list box taking the text value in the field ‘Group’ from the table ‘tblTeams’.
Both the values from the table ‘tblTeams’ as well as that from the list box (sourcing another table) are values.
Looking at the code, the list box value is correct but for some reason does not link to the table. I am wondering if there is something wrong with the syntax?
SELECT [tblTeams].[Department], [tblTeams].[Team], [tblTeams].[Group] FROM [tblTeams] ORDER BY [tblTeams].[Department] WHERE [tblTeams].[group]= '" & lstGroup.Value & "'"
Advertisement
Answer
Where clause needs to be before order by clause. See documentation
SELECT [tblTeams].[Department], [tblTeams].[Team], [tblTeams].[Group] FROM [tblTeams] WHERE [tblTeams].[group]= '" & lstGroup.Value & "'" ORDER BY [tblTeams].[Department]