>I want delete records of my emails.dbf, and copy them to a backup table called emails_ex.dbf
>
>In method keypress of column of my grid with belongs to emails.dbf
>
>*************************************************
>LPARAMETERS nKeyCode, nShiftAltCtrl
>
> IF nKeyCode = 7
>SELECT emails
> STORE emails.cod TO esteCOD
>
>SELECT emails_ex
> APPEND FROM emails FOR emails.cod = esteCOD
>
I think this should be
APPEND FROM emails FOR cod = esteCOD
You can also try
INSERT INTO emails_ex SELECT * FROM emails WHERE cod = esteCOD
Note that this makes the explicit assumption that the two tables have identical structures. If they don't then you could try
SELECT * FROM emails WHERE cod = esteCOD INTO CURSOR curTemp
SELECT emails_ex
APPEND FROM DBF('curTemp')
>SELECT emails
> LOCATE FOR emails.cod = esteCOD
> DELETE FOR emails.cod = esteCOD
The LOCATE is unnecessary since the default scope for your DELETE command is ALL. However, if the table is order by COD you could
LOCATE FOR emails.cod = esteCOD
DELETE WHILE emails.cod = esteCOD
Even better you could simply
DELETE FROM emails WHERE cod = esteCOD
>
>
> thisform.refresh
> ENDIF
>******************************************************
>
>The problems
>
>It is appending all records from emails.dbf and not only the selected record
>in the grid line
>
>After deleting it does not go to the line I was in, but go to the end of the grid,
>even if I assign: LOCATE FOR emails.cod = esteCOD
Doing the LOCATE won't get you anything since you have deleted those records. You should probably just do a GO TOP.
If the table is ordered by COD then you could also try
LOCATE FOR cod > esteCOD
which should put you on the next record after the ones you deleted