Hi,
Your SQL looks a bit strange.
You have used ";" in the IF statement and I don't know any database supporting the ";" as a separator in a IF statement.
I assume that you are using SQL Server.
Try to use IIF but don't use IF.
Which where clause do you want to create?
Didier