REPLACE .... WITH .... ; FOR packslip.studentid == cpack.studentid ; AND packslip.courseid == cpack.courseid in packslip The conditions in your FOR clause determine how many records get replacement values. Change the conditions so that you do only as many replacements as you want. If you only want to replace in that one record, take out the FOR... REPLACE defaults to NEXT 1. >My code isn't correct. I found out what the problem is. In the scan of cpack it takes the first record replaces all the records in packslip with it then goes to the next record of cpack and replaces all the records in packslip that match the courseid and studentid. So at the end I have the last record of cpack replacing all the records in packslip. Here is my code: <pre> >select cpack > scan > quant = iif(inlist(materialid,"VX29","VX39"), qty3, iif(inlist(materialid, "VX57","VX50"),qty2,iif(inlist(materialid, "VX51"),qty,iif(inlist(materialid,"CJ30","CJ31","CJ32","CJ33","CJ34","CJ35","CJ36","CJ37","CJ38","CJ39","CJ40"), "2","1")))) > quant = val(quant) > replace studentid with cpack.studentid, courseid with cpack.courseid,; > materialid with cpack.materialid, descript with cpack.description,; > qty with quant for packslip.studentid == cpack.studentid and packslip.courseid == cpack.courseid in packslip > select packslip > endscan>