use myTable local array laFields[1] local lnI, lnFields, lcSQL, lcWhere, lcSet lnFields = aFields(laFields) store '' to lcWhere, lcSet for lnI = 1 to lnFields lf laFields[m.lnI,2] = 'N' lcWhere = m.lcWhere + ' OR ' + laFields[m.lnI,1] + ' = 6' lcSet = m.lcSet + ', ' + laFields[m.lnI,1] + ; ' = IIF(' + laFields[m.lnI,1] +' = 6,4,' + laFields[m.lnI,1] + ')' && Keep the original value if not 6 endif next if not empty(m.lcWhere) lcSQL = 'UPDATE myTable SET ' + stuff(m.lcSet,1,1,'') + ' WHERE ' + stuff(m.lcWhere,1,4,'') endif ? m.lcSQL && to verify &lcSQLfrom the top of my head.