Before you change the SQL, is your Query deaktivated ? MyQuery.active:= false;you cannot change the sql on a active query.
Thats what I thought, but now another problem occurs wiih parameters.ZQuery complains that it cant find a parameter even if it is in the query. (The same code works fine in runtime created objects.