Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Record/Key Deleted Error

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I am deleting records programatically from a table indexed on the first two fields using...

Table2.Delete;

When I try to add new records to that table in a different unit I get the Record/Key deleted error as soon as I do...

Table2.Edit;

*However* if I exit the program and restart it everything works fine. I suspect the BDE is losing track of what records are in the table and throwing up this error. It seems similar to another problem I had with cached data not being written out which I fixed with FlushBuffers. Since I'm not editing the table per se but using the Delete method that won't work. Any ideas?

TIA

Paul
 
Have you tried using Table2.Insert; ? if so, does it do the same? Robertio
Alias: Robbie Calder
Software Developer
urc@walkermartyn.co.uk
 
Don't forget to call to Commit method of you database component after you've deleted a record, and if you're trying to edit second dataset linked to the same table you'll need to reopen it after deleting as well.

--- markus
 
The program is a relatively simple desktop (i.e. local)database app - I'm not using a specific Database component - just Datasources/Tables so 'Commit' is not an option.

In one unit I step through a table deleting any records where a certain field matches a user-entered value. I'm doing this with a 'While not Table2.Eof' loop comparing each record and deleting if necessary. It works fine.
(When I delete I don't do a 'Table2.Next' because the next record becomes current automatically.)

If I now switch to another part of the program (i.e. a different form)and try to add records into that same table (also programmatically, not via a control) I get the error as soon as it gets to Table2.Edit (the table just happens to be Table2 on both forms btw) . I've tried using 'Refresh', 'First' and even 'Edit' followed by 'Post' to try to get the thing to work! Arrhghhhh...


Paul
 
I have to agree with Robertio, you should try "Insert" instead of "Edit". If your tables are not updating, the program thinks you are trying to Edit a deleted record. Do you have "AutoRefresh" set to true on the table component? And are you using the same component for both forms? If not, are you refreshing the right one?

Cat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top