Hi Chris,
I know what you mean... I've tried macro subbing individual where clause segments before...
I don't know if it will help but you could try the following...
1) Store the entire SQL Statement as a variable and run it with Macro substitution...
e.g.
LOCAL lcSQLCmd
lcSQLCmd = "SELECT Customers.* FROM Customers WHERE "+ ;
lcSurname+ ;
" AND "+lcDepartment && etc...
&lcSQLCmd.
2) Store the entire WHERE clause to a variable and macro sub that.
e.g.
LOCAL lcWhere
lcWhere = lcSurname+ ;
" AND "+lcDepartment && etc...
SELECT * FROM Customers
WHERE &lcWhere.
I've also found that when using macro substitution where tables or table aliases are concerned that ending the macro sub with a full stop helps. I think it can confuse fox at times if there isn't one present, certainly in SQL statements.
I think string length will effect you the way you are firing your SQL statement now but I haven't had problems working the ways above.
HTH
Ben
Ben Sugden
"Remember to enjoy hunting - and that means relishing the search for the product that has never been advertised or placed handily at the front of the shop; Life begins on the uppermost shelf, avoid guide books and top 10's like the plague." - Ramsey Dukes