Modul.SourseQuery.SQL.Clear;
Modul.SourseQuery.SQL.Append('SELECT MAX(Pat_ID) AS LastPatID');
Modul.SourseQuery.SQL.Append('FROM Patient');
LastPatID:=Modul.SourseQuery.FieldByName('LastPatID').AsInteger;
Modul.IBOsmotr.SQL.Clear;
Modul.IBOsmotr.SQL.Append('Insert into Osmotr (Pat_ID,Date_ID,Doc_ID,Zhaloby,CHDD,CHSS,Weight,Height,Recom)');
Modul.IBOsmotr.SQL.Append('Values (:Pat_ID,:Date_ID,:Doc_ID,:Zhaloby,:CHDD,:CHSS,:Weight,:Height,:Recom)');
Modul.IBOsmotr.ParamByName('Pat_ID').AsInteger:=LastPatID;
Вот.........Переменной LAstPatID значение не присваивается в строчке:
LastPatID:=Modul.SourseQuery.FieldByName('LastPatID').AsInteger;
Поэтому значение и не заносится. Нуль постоянно считывает. До неё все рабочее. В IBConsole проверил...правильно считает.