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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems deleting a record in Access

Status
Not open for further replies.

amarti44

Programmer
Feb 16, 2001
23
0
0
US
Hi:

I'm using Access Database and I'm trying to delete a record from a table using the following code:

MyDataModule.tblPerson.Active := True;
MyDataModule.tblPerson.First;
while not MyDataModule.tblPerson.Eof do
begin
MyDataModule.tblPerson.Edit;
MyDataModule.tblPerson.Delete;
end;
MyDataModule.tblPerson.Active := False;

When the program tries to execute the Delete line, the following error message is displayed: Key violation [ODBC Microsoft Access Driver] Query is too complex.
 
Some questions: Why you don't use the bde engine, it is much more powerfull then ODBC. It is stream lined to work with Delphi..

Looking at the error you get I suspect that there are referential constraints on your table. Maybe there is a table which has a link to your tblPerson, and will not allow you to delete.

Again if you use the BDE with SQL explorer or Database explorer you can detect the relationships in your database.

Regards S. van Els
SAvanEls@cq-link.sr
 
Dear amarti44

by removing MyDataModule.tblPerson.Edit, will resolve this line

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top