>Al,
>
>>>- you can inadvertently step on existing memvar values unless you carefully manage their names
>
>The variables in the function are passed by value so don't affect existing variables.
>
>>>- If you just have 2 possible INSERT statements, run the correct one via IF...ENDIF as you suggest
>
>>>- If you have a few of them, use DO CASE...
>
>In fact the question referred to field1 "or any other field" meaning that a single IF does not answer the posed question. In fact you're into mathematical permutation needing at least 8 CASEs to cover all the possibilities for 3 fields. Hence my solution that cheerfully copes even as the number of fields increases past 3 and the permutations rise into the hundreds.
>
>What was interesting here was an OP suggesting that somebody trying to help, ought to be "constructive." An unusual attitude in VFP. I'll be sure not to offer my useless suggestions to such a person again. ;-)
Maybe we should reach out to "RV Boy". He might have some good suggestions :)
Truthfully, there is no simple elegant approach for what Dmitry was looking for. Your suggestion is no better and no worse than anything I or anyone else can come up with, given the context of the question.