Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Delete already!
Message
 
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Title:
Miscellaneous
Thread ID:
00130334
Message ID:
00130487
Views:
28
>>Your code is in the right place. You need to have NoDefault at the end while deleting the child records AND the parent record in the grid. That is the only way I got this to work correctly for deleting records in a grid. Example:
>>if MessgeBox("Really Delete This Record?") <> 6
>>   NoDefault
>>   Return 0
>>endif
>>lnSelect = Select()
>>select ChildTable
>>delete while ChildTable.KeyID = ParentTable.KeyID
>>select (lnSelect)  && presumably the parent table
>>delete next 1
>>* Note: you may need to add code to move record pointer
>>*       off deleted record to remove it from view.
>>this.refresh() && refresh grid
>>NoDefault
>
>This is basically the same as one of the ways I tried, except I just did "delete", not "delete next 1". Does that make a difference?
>
>Is there any difference between "delete while" and "delete all for"?
>
>Thanks,
>
>-Michelle

I made the assumption of a relation between parent and child table where the record pointer would be at the first child record that needs deleting. *Delete for child.key = parent.key* should be just as efficient since you have an index on the child key. I got in the habit of *delete next 1* when I started writing multi-user code because of implicit record locking. It also reaffirms to me that I am only wanting to explicitly delete the current record and not move the record pointer. I do not think it makes a difference in your case.
Mark McCasland
Midlothian, TX USA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform