Gracias por tu respueta, lo he probado y me sigue dando el error, incluso he borrado todos los registros de marcas, me muevo por los registros maestros y cierro el form, y todo bien, pero si vuelvo a entrar en el form me salta un error:
Al cambiar el id, realizo las siguientes operaciones:
Código Delphi
[-]
procedure TfmHorses.edIDChange(Sender: TObject);
var
DirImage, TypeBrand: String;
Left, Top, ID: Integer;
Img: TImage;
begin
inherited;
BindingExpressions(Sender);
DirImage := dsHorseImages.DataSet.FieldByName('imageName').AsString;
Image.Picture := NIL;
if RemoveWriteSpace(DirImage) <> '' then
begin
DirImage := iniPathImagesHorses + DirImage;
if fileExists(DirImage) then
Image.Picture.LoadFromFile(DirImage);
end;
Load_Brands;
end;
Aquí cargo las marcas:
Código Delphi
[-]
procedure TfmHorses.Load_Brands;
var
AName, TypeBrand:String;
NUM, ID, ALeft, ATop, I, Index:Integer;
begin
if BrandsLst.Count > 1 then
BrandsLst.Clear;
with dsHorseBrands.DataSet do
begin
if NOT(IsEmpty) then
begin
NUM := RecordCount;
while NOT(Eof) do
begin
ID := FieldByName('id').Value;
AName := FieldByName('name').Value;
ALeft := FieldByName('x').Value;
ATop := FieldByName('y').Value;
TypeBrand := iniPathImages + IMAGES_BRANDS + FieldByName('type').Value;
BrandsLst.Add(CreateBrand(AName, pnlReview, ALeft, ATop, TypeBrand, ID));
Next;
end;
end;
end;
y al cerrar el form, hago lo siguiente desde el form que hereda:
Código Delphi
[-]
procedure TfmAncestor.FormClose(Sender: TObject; var Action: TCloseAction);
var
I: Integer;
C: TComponent;
begin
Action := TCloseAction.caFree;
for I := 0 to ComponentCount - 1 do
begin
C := Components[i];
if (C is TDataSource) and (Assigned(TDataSource(C).DataSet)) then
begin
TDataSource(C).DataSet.Close;
if TDataSource(C).Name = 'dsAllRows' then
with TDataSource(C).DataSet as TClientDataSet do
CommandText := SQL;
end;
end;
end;
Acabo de realizar una pruebas, he eliminado la siguiente sentencia del procedimiento Load_Brands, y de esta forma no me da ningún error:
Código Delphi
[-]
if BrandsLst.Count > 1 then
BrandsLst.Clear;