mmmm me parece algo complicado tu codigo.. tienes muchas cosas que son redundantes
por ejemplo
Código Delphi
[-]
dmacceso.cdsClientes.Active := True; dmacceso.cdsClientes.Last; dmacceso.cdsClientes.Open;
dmacceso.cdsClientes.Insert;
yo particularmente hago esto
Boton Modificar del form donde muestro los datos
Código Delphi
[-]
procedure TfrmCatalogoAnexo.btnModificaClick(Sender: TObject);
begin
btn_opcion := 1;
qryAnexos.Edit;
frmCatalogoAnexod := TfrmCatalogoAnexod.Create(nil);
frmCatalogoAnexod.Show
end;
y en el create del formulario invocado hago mas o menos esto
Código Delphi
[-]
procedure TfrmCatalogoAnexod.FormCreate(Sender: TObject);
var i: Integer;
begin
if frmCatalogoAnexo.btn_opcion =1 then
begin
edtCodigo.Enabled := False;
ComboBox1.ItemIndex := StrToInt(frmCatalogoAnexo.qryAnexosTipoAnexo.Value) - 1;
end;
if frmCatalogoAnexo.btn_opcion >= 1 then
edtTipoAnexoExit(sender);
if frmCatalogoAnexo.btn_opcion = 2 then
begin
btnGrabar.Caption := 'Eliminar';
for i := 0 to (Self.ComponentCount - 1) do begin
if (Self.Components[i] is TDBEdit) or (Self.Components[i] is TComboBox) then begin
TEdit(Self.Components[i]).Enabled := False;
end;
end;
end;
end;
y en el boton de grabar hago mas o menos esto
Código Delphi
[-]
procedure TfrmCatalogoAnexod.btnGrabarClick(Sender: TObject);
begin
if frmCatalogoAnexo.btn_opcion <> 2 then
begin
frmCatalogoAnexo.qryAnexosTipoAnexo.AsString := FormatFillStringNumber (IntToStr(ComboBox1.ItemIndex + 1),2);
frmCatalogoAnexo.qryAnexosEmpresa.AsString := dmGlobal.g_CodigoEmpresa;
frmCatalogoAnexo.qryAnexos.Post;
end;
if frmCatalogoAnexo.btn_opcion = 2 then
frmCatalogoAnexo.qryAnexos.Delete;
Close;
frmCatalogoAnexo.dbgAnexo.SetFocus;
end;