You don't need the macro substitution in this case, Name Expression wiil do
lcfieldname = "field" + Transform(lnCnt)
lcvalue = "myvalue"
SELECT mytable
REPLACE (lcfieldname) WITH lcvalue
lnCnt = lnCnt + 1
Make sure that the field name, you're creating, is valid one.
>Hi all
>
>Has anyone had any success using macro (&) expansion with the REPLACE command?
>
>I am attempting to use a loop with a REPLACE inside the loop. The field names and the values to be replaced change with every iteration. I am using macro substitution, the values are correct asigned, but REPLACE crashes every time with an unrecognized command or syntax error, depending on the circumstances.
>
>The code is like this:
>
>lcfieldname = "field" + INT(VAL(lnCnt)) && ex. to illustrate changing field name
>
>lcvalue = "myvalue"
>SELECT mytable
>REPLACE &lcfieldname WITH lcvalue
>lnCnt = lnCnt + 1
>
>Any suggestions would be appreciated.
>
>Thanks
>Donald Lowrey
--sb--