Debug your code so that you can see the final statement after the SQL string has been built. i.e. set a watch on the variable that holds your completed SQL string, or better:
debug.print yourSQLStringVariable
If the problem isn't obvious from inspecting that, please post the result of that debug line. You could also try using the text that is printed to debug (immediate window) in the SQL view of the query builder, then try to run the query.
I can't help you without seeing the complete SQL statement.
Simon