Тема: БД Access
Показать сообщение отдельно
  #1  
Старый 14.05.2014, 22:58
MotoArhangel MotoArhangel вне форума
Новичок
 
Регистрация: 14.10.2012
Сообщения: 58
Версия Delphi: Delphi 10.4
Репутация: 10
По умолчанию БД Access

Не могу считать некоторые данные из БД для дальнейшего занесения в Word.
Вот с этой частью базы работаю:
http://www.delphisources.ru/forum/at...d=140009331 4

Добавляю в MS WORD:
Код:
   //Нормально заменяет строки в WORD'е $$$Group$$$ и $$$Course$$$ на данные из таблицы
   Group:=DM.FindStudentInfo(DM.qStudents.Fields[0].AsInteger, 3);
   FindAndReplace('$$$Group$$$', Group);
   Course:=DM.FindStudentInfo(DM.qStudents.Fields[0].AsInteger, 6);
   FindAndReplace('$$$Course$$$', Course);

   //Оставляет без замены
   DateBegin:=DM.FindStudentInfo(DM.qStudents.Fields[0].AsInteger,10);
   FindAndReplace('$$$DateBegin$$$', DateBegin);
   DateEnd:=DM.FindStudentInfo(DM.qStudents.Fields[0].AsInteger, 11);
   FindAndReplace('$$$DateEnd$$$', DateEnd);

Сам поиск.
Код:
function TDM.FindStudentInfo(ID: integer; N: integer): string;
var LookupRes: Variant; Gr: string;
begin
   if not tStudents.Active then tStudents.Open;
   LookupRes := tStudents.Lookup ('IDStudent', ID, 'Surname;Name;Patronymic;Group;State');
   if not VarIsNull(LookupRes) then
   begin
      if N>4 then
      begin
         Gr:=VarToStr(LookupRes[3]);
         if not tGroups.Active then tGroups.Open;
         LookupRes := tGroups.Lookup ('Group', Gr, 'Speciality;Course;Form;DateBegin;DateEnd');
         if not VarIsNull(LookupRes) then result:=VarToStr(LookupRes[N-5])
         else result:='';
         if (N=5) and (result<>'') then
         begin
            Gr:=result;
            if not tSpeciality.Active then tSpeciality.Open;
            LookupRes := tSpeciality.Lookup ('Code', Gr, 'Speciality;Base');
            if not VarIsNull(LookupRes) then result:=gr+' '+VarToStr(LookupRes[0])
            else result:=Gr;
         end;
      end
      else result:=VarToStr(LookupRes[N]);
   end
   else result:='';
end;

Где что не так?
Изображения
Тип файла: bmp 2014-05-15_1-47-12.bmp (215.6 Кбайт, 9 просмотров)
Ответить с цитированием