Ulises,
So the problem is in the following section.
SELECT TABLE2
LOCATE FOR idSTD=TABLE1.idSTD
REPLACE OWE WITH TABLE1.OWE
There could be several reasons:
1. TABLE2 is involved in a relation (SET RELATION) with TABLE1, so the LOCATE does change the record pointer in table2
2. The REPLACE triggers a procedure that changes the record pointer in table 2.
3 ... ?
The only way you can determine the cause is by STEPping through your code and see what is happening after each command. so, ADD a SET STEP ON before the SCAN, Open the two tables in a browse window and step through the code.
Walter,
>This works fine:
>
>Select Table1
>Scan FOR owe <>0
>Endscan
>
>It goes through all the records and exits when reaching the end of the table. So it looks like the problem is when SELECTing TABLE2 and working with it. Would this mean that the index on TABLE2 is corrupted? If so, how to fix it?
>
>TIA
>
>Ulises