I've tried to find an answer in the posts that are similar but I can't find where I need to put a extra syntax or remove one.
The query on its own works if I put it in a listbox recordset in the property window as:
SELECT Overzicht_codes.code_compleet AS Code, Overzicht_codes.omschrijving1, Overzicht_codes.omschrijving2, Overzicht_codes.omschrijving3, Overzicht_codes.omschrijving4, Overzicht_codes.omschrijving5, Overzicht_codes.omschrijving6
FROM Overzicht_codes
WHERE (((Nz([opleidingniveau]=[Forms]![OverzichtOpleidingen].[cbOpleiding],[opleidingniveau]))<>False)
AND ((Nz([subniveau]=[Forms]![OverzichtOpleidingen].[cbopleidingniveau],[subniveau]<>False))<>False)
AND ((Nz([studiegroep]=[Forms]![OverzichtOpleidingen].[cbstudiegroep],[studiegroep]<>False))<>False)
AND ((Nz([studierichting]=[Forms]![OverzichtOpleidingen].[cbstudierichting],[studierichting]<>False))<>False))
ORDER BY Overzicht_codes.code_compleet;
Now I want to have the same code in VBA as a kind of 'reset'. For VBA it needed some altering:
SQL = "SELECT Overzicht_codes.code_compleet AS Code, Overzicht_codes.omschrijving1, Overzicht_codes.omschrijving2, Overzicht_codes.omschrijving3, Overzicht_codes.omschrijving4, Overzicht_codes.omschrijving5, Overzicht_codes.omschrijving6 " _
& "FROM Overzicht_codes " _
& "WHERE (((Nz([opleidingniveau]= " & Me.cbOpleiding & ",Overzicht_codes.[opleidingniveau]))<>False) " _
& "AND ((Nz([subniveau]= " & Me.cbOpleidingNiveau & ",Overzicht_codes.[subniveau]<>False))<>False) " _
& "AND ((Nz([studiegroep]= " & Me.cbStudiegroep & ",Overzicht_codes.[studiegroep]<>False))<>False) " _
& "AND ((Nz([studierichting]= " & Me.cbStudierichting & ",Overzicht_codes.[studierichting]<>False))<>False)) " _
& "ORDER BY Overzicht_codes.[code_compleet]"
I've read something about putting an extra '
in string parts of the code. But after several tries it still gives the error.
For an extra insight the error message is below:
Who can help me give insight in what I did wrong or what I forgot?