LPARAMETERS tnRecNo LOCAL lcAlias, loColumn lcAlias = Thisform.Grid1.recordSOurce *** The current record may not be the one we are trying to delete, that is, *** the paramter to the deleted() method (nRecoNo) may not be the same as RECNO() *** and if we just added it, RECNO( .RecordSource ) WILL be a negative number but nRecNo *** will be a positive one! So if you are using table buffering and not TABLEUPDATEing *** the grid's RecordSOurce until later, you need more checks before you just GO tnRecNo GO tnRecNo IN ( lcAlias ) IF DELETED( lcAlias ) RECALL IN ( lcAlias ) ELSE DELETE IN ( lcAlias ) *** Must do a TableUpdate as soon as the record is deleted. Otherwise, *** when it is recalled, you will get a PK violation IF ! TABLEUPDATE ( 0, .F., lcAlias ) MESSAGEBOX( 'Unable to Update Table', 48, 'So Sorry!' ) ENDIF ENDIF SELECT ( lcAlias ) COUNT TO lnRecCount FOR NOT DELETED() lnItemno = 0 SCAN FOR NOT DELETED() lnItemno = lnItemno + 1 REPLACE Itemno WITH lnItemno ENDSCAN THISFORM.TEXT13.VALUE = lnItemNoThis code goes in the grid's Deleted) method. No other code should be in the deleted method():
LPARAMETERS nRecNo This.DeleteRecord( nRecNo ) NODEFAULTThe parameters statement should already be there.