Buenos días, estoy tratando de obtener la suma de un campo llamado Importe y pasar el resultado a un Label,
pero me dice que mi variable no existe.
Mi código es el siguiente
Código Delphi
[-]procedure TfrmAdminColeg.Button3Click(Sender: TObject);
var
TotalImporte, Total: Double;
begin
DM.CuentasPorCobrar.SQL.Clear;
DM.CuentasPorCobrar.SQL.Add('SELECT SUM(importe) AS Total FROM CuentasPorCobrar');
DM.CuentasPorCobrar.Open;
if not DM.CuentasPorCobrar.FieldByName('Total').IsNull then
begin
TotalImporte := DM.CuentasPorCobrar.FieldByName('Total').AsFloat;
Label4.Caption := FormatFloat('0.00', TotalImporte); end
else
begin
Label4.Caption := '0.00';
end;
DM.CuentasPorCobrar.Close;
end;
Me da el siguiente error