A: Call the following function when you want to toggle between states. There is no need to close and re-open the table when toggling like this. To call, send as arguments name of TTable and TRUE/FALSE depending to show/not show deleted records.
Example code:
uses DBITYPES, DBIERRS, DBIPROCS;
procedure TForm1.SetDelete(OurTable: TTable; ShowDeleted: Boolean);
var
rslt: DBIResult;
szErrMsg: DBIMSG;
begin
try
OurTable.DisableControls;
try
rslt := DbiSetProp(hDBIObj(OurTable.Handle),
curSOFTDELETEON,
LongInt(ShowDeleted));
if rslt <> DBIERR_NONE then
begin
DbiGetErrorString(rslt,
szErrMsg);
raise Exception.Create(StrPas(szErrMsg));
end;
except
on E: EDBEngineError do ShowMessage(E.Message);
on E: Exception do ShowMessage(E.Message);
end;
finally
OurTable.Refresh;
OurTable.EnableControls;
end;
end;
{
This goes on the OnClick() event of a checkbox where the ShowDeleted
of the checkbox indicates whether we want to see the deleted records or
not.
}
procedure TForm1.CheckBox1Click(Sender: TObject);
begin
SetDelete(Table1, checkbox1.checked);
end;
end.