this question seems to be ... but I tried many times to do it but I couldn't .
I'm using VFP 6.0 .
I created a form and take data from mytable . After that I created Del button and wrote a small code in Click event .
This is my code :
if messagebox("Do you want to del this record ",36,"Notice")=6
delete
thisform.refresh
and the result is 0 record deleted .
I don't know why . Is this related to "primary key" from mytable .
If someboby know , please tell me . Thanks so much .
This is my email : mrbxp@yahoo.com . If you have some help files of VFP about form , event , class , .... please send it to me . Thanks so much .
-^^- : Now I'm learning english , if i say sth wrong .....

delete record
Donnie H
if messagebox("del this record ",36,".....")=6
delete
thisform.refresh
pack
endif
I tried CURSORSETPROP() and it worked well .
You're right , I have to find someone really knows VFP to help me.
Thanks for helping me .
itanium7000
Hi!
When you say you "take data from MyTable" do you mean that you are showing the data in the form or that you have selected it into a temporary cursor
Are you sure that the table you want is the current work area You can also say Delete In MyTable to handle cases when the table you want is not the current work area.
Do you move the record pointer after your delete operation
David2482
"Command can't be issued on a table with cursors in table buffering mode " .
this is my code :
if messagebox("Del it ",36,"Careful")=6
delete
pack
thisform.refresh
endif
I scanned mytable , this messege "This one is flagged for delete" always appear .
Matt Peirse
>>Thanks for helping me
Sorry I can't do more, but if you can find someone locally to assist you things will go much faster. Where are you located There are lists of people in various places on line and you may be able to find someone to help you out....
Good luck.
74MGB
How do you know that it did not work
In VFP a deleted record is flagged for deletion, and remains in the table until you actually issue a PACK command (which requires exclusive use).
SET DELETED controls whether records that are marked for deletion remain visible - if it is OFF then you can still see deleted records, if it is ON you cannot
You can test a record to see whether it is marked by deletion using the DELETED() function:
SELECT [table]
SCAN
IF DELETED()
MESSAGEBOX( "This one is flagged for delete" )
ENDIF
ENDSCAN
The setting of DELETED is scoped to the data session so even if you have SET DELETED ON in your startup program, forms that use Private Datasessions will be running with DELETED=OFF unless you explicitly set it in their startup
RajatTalwar
I need an explaination ..
When I remove index (primary key) from mytable ( I use "docID" as my primary key and set it " not null" ) , now I easily to delete a record in form . I don't know why .
Please help me , thanks so much .
Samuel Hobbs
0-default
1-pessimistic
2-optimistic
. They don't have 5 choices as VFP 9.0 .
You cannot set this using the form property - I told you, use CURSORSETPROP() it is a function.
>> And then when I use your code , all I need is delete only 1 record in form but it deleted all records . And when I quit form and come back , there are still all records before I deleted .
I have no idea what you are talking about. My code deletes one, and only one, record.
>>Maybe , it's time for me to try VFP 9.0
No, maybe it's time for you to either [1] post your exact code, or [2] find someone who actually knows VFP to do this for you. Clearly you do not have enough understanding to do this, and obviously I am not helping you. I cannot do it for you, and if you cannot figure it out from the code and references I have given you then you need to get some more expert assistance.
Jules
This time I selected 1 current record in form and I wanted to del it but it didn't work . Of course after I delete successfully , I want to move the record pointer ( ex : skip -1 ) .
Rafa Cabedo
I'm using VFP 6.0 . When I config cursor in BufferMode . There are 3 choices :
0-default
1-pessimistic
2-optimistic
. They don't have 5 choices as VFP 9.0 .
And then when I use your code , all I need is delete only 1 record in form but it deleted all records . And when I quit form and come back , there are still all records before I deleted .
Maybe , it's time for me to try VFP 9.0 .
Alex2004
>> If I add PACK command into my code . There is an error :
"Command can't be issued on a table with cursors in table buffering mode " .
That is correct. You cannot pack records when the table is using Table Buffering. Use CursorSetProp() to change the buffer mode to Row before trying to remove deleted records.
You also need exclusive use before packing records, so this is not usually done in application code but in a maintenance routine.
>> I scanned mytable , this messege "This one is flagged for delete" always appear .
Than your delete WAS working and you have flagged all records in your table for deletion. You can use RECALL to un-mark records that have been previously marked for deletion (which is the whole point of the two-step process anyway - a delete in VFP is NOT actually final).
The correct way to delete a record is:
*** In your Form/Environment set-up
SET DELETED ON
*** Delete code
IF MESSAGEBOX( "Are You Sure " ) = 6 && YES
DELETE
SKIP
IF EOF()
GO BOTTOM
ENDIF
*** Refresh controls here
ThisForm.Refresh()
ENDIF
This will work!
Phil Huang
Without seeing your code, there is nothing more I can tell you.