Hello:
the code doesn't work for several reasons:
First eror:
MSDBQuery.FieldDefs.Dataset.Delete;
only do this
MSDBQuery.Delete;
but when you delete a record, the next record became the active record, then you pass to the next record (MSDBQuery.next), and jump one record.
Supose this dataSet
A<-Active record
B
C
D
if record A must be deleted, the dataSet
B<-Active record
C
D
Now, do next
B
C<-Active record
D
is not checked if record B must be deleted!!!....
You must modify your code like this:
if MyDBQuery.Locate('inc', MSDBQuery.FieldByName('inc').Value, []) then
begin
MSDBQuery.FieldDefs.Dataset.Delete;
end else MSDBQuery.Next;