>The code works well EXCEPT that please look at the following code that generates all the OR conditions:
...
>I'm getting an error that the SQL statement is too long, probably because there are so many fields to process. How can I solve this?
Split that after some number of fields and build three, four cursors (or as many as it takes), so that the field list for each one of them is short enough. Then select... union them into one, assuming you don't have any memos in there.