Can't Delete Records from an MS Access DB



I am trying to use the following code to remove a group of records from an TAdoTable connected to an MS Access DB. When I evoke the DeleteRecord I receive an exception the "Operation is not allowed in this context".
Do I have to set the cursor type? I have tried entering "Edit" mode but I still get the error. What am I not doing? I do not know enough SQL to delete the records directly from the DB. If that would be better I would need some instruction.

The DM is the datamodule where the ADOConnections components live. AllocationID is an Indexed (dup=YES) field.

Tbl := TADOTable.Create( Self );
try
with Tbl do // return all records with the AllocationID
begin
Connection := DM.Allocations;
TableName := 'Allocated';
Filter := format( 'AllocationID = %d',[AllocationId]);
Filtered := TRUE;
Open;
if (RecordCount > 0) and Supports( [coDelete] ) then
DeleteRecords(arAll);
end;
finally
Tbl.Free;
end; { try/finally }
.



Relevant Pages

  • DeleteRecord raises and Exception
    ... When I evoke the DeleteRecord I receive an exception the "Operation is not allowed in this context". ... with Tbl do // return all records with the AllocationID ...
    (borland.public.delphi.database.ado)
  • Re: Cant Delete Records from an MS Access DB
    ... Brian Bushay TeamB wrote: ... with Tbl do // return all records with the AllocationID ...
    (borland.public.delphi.database.ado)
  • Re: Cant Delete Records from an MS Access DB
    ... with Tbl do // return all records with the AllocationID ... Connection:= DM.Allocations; ... TableName:= 'Allocated'; ...
    (borland.public.delphi.database.ado)