I manged to have the SQL working using the follwoing thanks for the suggestion of using AND:
strSQL = "SELECT [SAL_1].EMPLOYEE, [SAL_1].NAME_F_N, [SAL_1].FUNCTION, [SAL_1].AFF_REG, [TEST DATABASE].* FROM [TEST DATABASE] LEFT JOIN SAL_1 ON [TEST DATABASE].Employee = SAL_1.ID " & _
"WHERE [TEST DATABASE].[Tests] " & testresult & " AND [SAL_1].FUNCTION " & functionresult & " AND [SAL_1].AFF_REG " & districtresult & " AND [SAL_1].COMPANY " & companyresult & " AND CInt(Left([SAL_1]![EMPLOYEE],3)) " & localresult & " AND [SAL_1].[IN_OUT] = 0 ;"
Now I am confronted with the follwoing SQL which access doesn't like when I put OR:
strSQL = "SELECT DISTINCT [SAL_1].EMPLOYEE, [SAL_1].NAME_F_N, [SAL_1].FUNCTION, [SAL_1].AFF_REG, [TEST DATABASE].[tests] FROM [SAL_1] LEFT JOIN [TEST DATABASE] ON [SAL_1].ID = [TEST DATABASE].Employee " & _
"GROUP BY [SAL_1].EMPLOYEE, SAL_1.NAME_F_N, SAL_1.FUNCTION, SAL_1.AFF_REG, [TEST DATABASE].Tests, SAL_1.COMPANY, CInt(Left([SAL_1]![EMPLOYEE],3)), SAL_1.IN_OUT " & _
"HAVING [TEST DATABASE].[Tests] " & testresult & " AND [TEST DATABASE].[employee] " & employeresult & " AND [SAL_1].FUNCTION " & functionresult & " AND [SAL_1].AFF_REG " & districtresult & " AND [SAL_1].COMPANY " & companyresult & " AND CInt(Left([SAL_1]![EMPLOYEE],3)) " & localresult & " AND [SAL_1].[IN_OUT] = 0 " & _
"OR [TEST DATABASE].[Tests] " & testniet & " AND [TEST DATABASE].[employee] " & employeniet & " AND [SAL_1].FUNCTION " & functionresult & " AND [SAL_1].AFF_REG " & districtresult & " AND [SAL_1].COMPANY " & companyresult & " AND CInt(Left([SAL_1]![EMPLOYEE],3)) " & localresult & " AND [SAL_1].[IN_OUT] = 0 ;"
I want that the query looks for records based on certain variables or other depednant variables. For example if Test = 3 then Id = Like'*' and if Test = Like '*' then id = Like'*'
In the baove statement the 2 dependant variables are testresult with testniet and employeresult with employeniet.
Thanks for any suggestion.