Me Respondo, revisando la consulta tuve un error grave, quedo de la siguiente manera el error lo pongo en engritas y otro color.
Código Delphi
[-]
procedure TFcobro.ultimo_pago;
var wcontrato_meses:string;
wanio_ejercicio:string;
begin
wanio_ejercicio:=FormatDateTime('yyyy',Date);
wcontrato_meses:=Trim(Self.txtcontrato.Text);
if wcontrato_meses<>'' then
begin
with fmodulo.Qry_Temp do
begin
sql.Clear;
SQL.Add('SELECT contrato,anio, Max(Fecha) AS Fecha');
sql.Add('from recibo');
sql.Add('group by contrato,anio');
sql.Add('having (((contrato)=:Pcontrato) and ((anio)=:Panio))');
Parameters.ParamByName('Pcontrato').Value:=Trim(wcontrato_meses);
Parameters.ParamByName('Panio').Value:=Trim(wanio_ejercicio);
try
Self.txt2.Text:=SQL.Text;
Open;
if not Fmodulo.Qry_Temp.IsEmpty then
begin
while not Fmodulo.Qry_Temp .Eof do
begin
self.L_ultimaFechaPago.Caption:=DateToStr(FieldByname('Fecha').AsDateTime);
Next;
end;
end;
except
on e: EoleException do
begin
MessageDlg(Format('Error: %s Codigo: %d', [E.Message, E.ErrorCode]), mtError, [mbOK], 0);
end;
end;
end;
end;
end;