SELECT table1 SCAN SELECT tempCursor LOCATE FOR cLegend = CMONTH(table1.date) IF NOT FOUND() APPEND BLANK ENDIF REPLACE Credit WITH Credit + table1.Credit, ; cLegend WITH CMONTH(table1.date) ENDSCANHere's the reasoning for the adjustments I have made. It is a bad idea to use the alias in a replace command as it can cause weird behavior if the incorrect alias is selected when the replace executes. By leaving the alis off of the field names you will get an error if the worng table is selected. Also you can replace more than one field in a single replace command. You don't need seperated replace statements as the append blank will create a record with the Credit field equal to zero so you can add the value from Table1 just like you do if the record in there. The append blank does not need the IN clause because Tempcursor is the current alias anyway.
SELECT table1 SCAN SELECT tempCursor LOCATE FOR tempCursor.CLEGEND = CMONTH(table1.date) IF NOT FOUND() APPEND BLANK IN tempCursor replace tempCursor.credit WITH table1.credit replace tempCursor.cLegend WITH CMONTH(table1.data) && Data should be Date ELSE REPLACE tempCursor.CREDIT WITH tempCursor.credit + table1.CREDIT replace tempCursor.cLegend WITH CMONTH(table.date) && Table should be table1 ENDIF ENDSCAN