Hola steelha.
Mirando tu código, yo tampoco me explico ese error si el campo ID existe y con ese nombre... Por si estuvieras utilizando el mismo componente en otra parte del código, intenta salvando y restaurando la consulta original:
Código Delphi
[-]
function TGenerador.GetActiveServiceStation: Integer;
var
MaxRegs : Integer;
OldSQL : string;
begin
with dm.qryEstaciones do
begin
OldSQL := SQL.Text;
Close;
SQL.Text := 'SELECT COUNT(*) AS MAX_REG FROM tblRepresentante WHERE ACTIVO = ''S'' ';
Open;
if isEmpty then
raise Exception.Create('No hay estaciones de servicio activas');
MaxRegs := FieldByName('MAX_REG').AsInteger;
Close;
SQL.Text := 'SELECT ID FROM tblRepresentante WHERE Activo = ''S'' ';
Open;
Randomize;
Locate('ID', Random(MaxRegs), []);
Result := FieldByName('ID').AsInteger;
Close;
SQL.Text := OldSQL;
end;
end;
Saludos.