Ir para conteúdo
Fórum Script Brasil
  • 0

Erro de violation no relatório...


robinhocne

Pergunta

Na primeira vez que eu executo o relatório dá tudo certo, mas quando eu vou rodar ele de novo ele dá esse erro:

Access violation at address 00404AA0 in nodule 'sistemacfc.exe'. Write of address 00000244.

esse é o meu codigo fonte :

var
  frmLisRelPraSemanais: TfrmLisRelPraSemanais;
  data, HorIni, HorFin, aluno, Inst, Cat :TQRLabel;
   i, a, b, c, d, e, Cont, soma, x, y, z :integer;
   SomaData, HrF : Integer;

implementation

uses fdtmiza, FRelPraSemanal, Praticas, FRelSemanal, IBQuery, FPrincipal, FPesquisa, funcoes;

{$R *.dfm}

procedure TfrmLisRelPraSemanais.spbfecClick(Sender: TObject);
begin
  Close;
end;

procedure TfrmLisRelPraSemanais.spbexiClick(Sender: TObject);
begin


  Application.CreateForm(TQrSemanal,QrSemanal);

   // Coluna das Datas
   for i:=1 to 7 do
      begin
        data                   := TQRLabel.Create(self);
        data.Name              := 'Dat'+inttostr(i);
        data.Left              := -40+(i*135);
        data.top               := 50;
        data.Frame.DrawTop     := true;
        data.Frame.DrawBottom  := true;
        data.Frame.DrawLeft    := true;
        data.Frame.DrawRight   := true;
        data.Transparent       := true;
        data.Width             := 130;
        data.Font.Size         := 12;
        data.Height            := 21;
        data.Font.Name         := 'Arial';
        data.Font.Style        := [fsBold];
        data.AutoSize          := false;
        data.Caption           := DateToStr(DataInicial.Date-1 + i);
        data.Alignment         := TaCenter;
        data.Parent            := QrSemanal.QRBand1;
      end;

 // coluna de horarios
   for a:=1 to 16  do
      begin
        HorIni                   := TQRLabel.Create(self);
        HorIni.Name              := 'Hor'+inttostr(a);
        HorIni.Left              := 4;
        HorIni.Height            := 23;
        HorIni.Frame.DrawTop     := true;
        HorIni.Frame.DrawBottom  := true;
        HorIni.Frame.DrawLeft    := true;
        HorIni.Frame.DrawRight   := true;
        HorIni.Transparent       := true;
        HorIni.AutoSize          := false;
        HorIni.Width             := 43;
        HorIni.Font.Size         := 10;
        HorIni.Font.Name         := 'Arial';
        HorIni.Font.Style        := [fsBold];
       // hora.Caption           := inttostr(6+a)+':00';
        HorIni.Caption           := '';
        HorIni.Alignment         := tacenter;
        HorIni.top               := 50+(a*25);
        HorIni.Parent            := QrSemanal.QRBand1;
      end;

 // coluna de horarios
   for HrF:=1 to 16  do
      begin
        HorFin                   := TQRLabel.Create(self);
        HorFin.Name              := 'HorFin'+inttostr(HrF);
        HorFin.Left              := 50;
        HorFin.Height            := 23;
        HorFin.Frame.DrawTop     := true;
        HorFin.Frame.DrawBottom  := true;
        HorFin.Frame.DrawLeft    := true;
        HorFin.Frame.DrawRight   := true;
        HorFin.Transparent       := true;
        HorFin.AutoSize          := false;
        HorFin.Width             := 43;
        HorFin.Font.Size         := 10;
        HorFin.Font.Name         := 'Arial';
        HorFin.Font.Style        := [fsBold];
       // hora.Caption           := inttostr(6+a)+':00';
        HorFin.Caption           := '';
        HorFin.Alignment         := tacenter;
        HorFin.top               := 50+(HrF*25);
        HorFin.Parent            := QrSemanal.QRBand1;
      end;


         //criacao do QrLabel do Instrutor
        begin
          Inst                   := TQRLabel.Create(Self);
          Inst.Name              := 'Ins';
          Inst.Left              := 104;
          Inst.top               := 480;
          Inst.Frame.DrawTop     := true;
          Inst.Frame.DrawBottom  := true;
          Inst.Frame.DrawLeft    := true;
          Inst.Frame.DrawRight   := true;
          Inst.Transparent       := true;
          Inst.AutoSize          := false;
          Inst.Width             := 300;
          Inst.Font.Size         := 12;
          Inst.Font.Name         := 'Arial';
          Inst.Parent            := QrSemanal.QRBand1;
        end;

   soma := 0;
   for b:=1 to 16  do // total de aluno um em baixo do outro
     for c := 1 to 7 do // total de coluna de aluno
        begin

        soma := Soma + 1;
          aluno                   := TQRLabel.Create(Self);
          aluno.Name              := 'Al'+inttostr(soma);
          aluno.Left              := -40+(c*135);
          aluno.top               := 50+(b*25);
          aluno.Frame.DrawTop     := true;
          aluno.Frame.DrawBottom  := true;
          aluno.Frame.DrawLeft    := true;
          aluno.Frame.DrawRight   := true;
          aluno.Transparent       := true;
          aluno.AutoSize          := false;
          aluno.Width             := 130;
          aluno.Font.Size         := 9;
          Aluno.Height            := 22;
          aluno.Font.Name         := 'Arial';
          Aluno.Font.Style        := [fsBold];
          aluno.Caption           := '';
          aluno.Parent            := QrSemanal.QRBand1;
        end;

      //mostrar o nome do instrutor
     With DtmIza.QryPraticas do
        begin
          close;
          sql.Clear;
          sql.add('Select Codigo, Nome from Instrutores where codigo ='+ TxtInst.Text);
          open;
        end;
     If  not DtmIza.QryPraticas.IsEmpty then
          begin
             TQRLabel(FindComponent( 'Ins' )).Caption := DtmIza.QryPraticas.FieldByName('Nome').AsString;
          end;


   // pesquisa de Horarios
   with dtmiza.QryIza do
     begin
       close;
       sql.clear;
       sql.add ('Select HorarioInicial, HorarioFinal, Instrutor from HorariosPraticas where Instrutor =:Ins');
       ParamByName('Ins').AsString := TxtInst.Text;
       open;
     end;
   Cont := 1;
   while not dtmiza.QryIza.Eof do
     begin
       TQRLabel(FindComponent( 'Hor' + IntToStr(Cont))).Caption := FormatDateTime('hh:nn', dtmiza.QryIza.FieldByName('HorarioInicial').AsDateTime);
       TQRLabel(FindComponent( 'HorFin' + IntToStr(Cont))).Caption := FormatDateTime('hh:nn', dtmiza.QryIza.FieldByName('HorarioFinal').AsDateTime);
       DtmIza.QryIza.Next;
       Cont := Cont + 1;
     end;

   // pesquisa de alunos
   for x:=1 to 16 do
   begin
      for y:=1 to 7 do
      begin
        z:=z+1;

        if  TQRLabel(FindComponent( 'Hor' + IntToStr(x))).Caption <>'' then
        begin
          DtmIza.QryPraticas.close;
          DtmIza.QryPraticas.sql.Clear;
          DtmIza.QryPraticas.sql.Add('select p.instrutor, p.horario, p.data, p.aluno, p.bloqueado, a.codigo, a.nome from praticas p, alunos a'
                                     +' where instrutor =:inst and horario =:hor and data =:dat and p.aluno = a.codigo');
          DtmIza.QryPraticas.ParamByName('Inst').AsString := TxtInst.Text;
          DtmIza.QryPraticas.ParamByName('dat').AsDate    := StrtoDate(TQRLabel(FindComponent('Dat' + IntToStr( y ) ) ).Caption);
          DtmIza.QryPraticas.ParamByName('hor').AsTime    := StrToTime(TQRLabel(FindComponent( 'Hor' + IntToStr(x))).Caption);
          DtmIza.QryPraticas.open;
        end;

    if not DtmIza.QryPraticas.IsEmpty then
        begin
          if DtmIza.QryPraticas.FieldByName('Bloqueado').AsString = 'S' then
            begin
              TQRLabel(FindComponent( 'Al' + IntToStr(z))).Caption:= ' **********************';
            end;
            //else
           // begin
              TQRLabel(FindComponent( 'Al' + IntToStr(z))).Caption := ' ' + DtmIza.QryPraticas.FieldByName('nome').asstring;
           // end;
       end;
     end;
   end;


   QrSemanal.Preview;
   QrSemanal.Free;
   DtmIza.QryPraticas.close;
   close;


 end;

Link para o comentário
Compartilhar em outros sites

2 respostass a esta questão

Posts Recomendados

  • 0
Na primeira vez que eu executo o relatório dá tudo certo, mas quando eu vou rodar ele de novo ele dá esse erro:

Access violation at address 00404AA0 in nodule 'sistemacfc.exe'. Write of address 00000244.

Este erro acontece em virtude deste codigo

Application.CreateForm(TQrSemanal,QrSemanal);
   ///
   ///
   ///
   QrSemanal.Preview;
   QrSemanal.Free;
Altere o codigo deste maneira
try
      if QrSemanal = Nil then
         QrSemanal := TQrSemanal.Create(self);
   except
         ShowMessage('Erro na criação do relatório!!');
         exit;
   end;

   QrSemanal.Prepare;
   QrSemanal.PreviewModal;
   QrSemanal.Free;
   QrSemanal := Nil;

abraço

Link para o comentário
Compartilhar em outros sites

  • 0
Na primeira vez que eu executo o relatório dá tudo certo, mas quando eu vou rodar ele de novo ele dá esse erro:

Access violation at address 00404AA0 in nodule 'sistemacfc.exe'. Write of address 00000244.

Este erro acontece em virtude deste codigo

Application.CreateForm(TQrSemanal,QrSemanal);
   ///
   ///
   ///
   QrSemanal.Preview;
   QrSemanal.Free;
Altere o codigo deste maneira
try
      if QrSemanal = Nil then
         QrSemanal := TQrSemanal.Create(self);
   except
         ShowMessage('Erro na criação do relatório!!');
         exit;
   end;

   QrSemanal.Prepare;
   QrSemanal.PreviewModal;
   QrSemanal.Free;
   QrSemanal := Nil;
abraço
isso dai eu vou colocar no lugar disso:
QrSemanal.Preview;
   QrSemanal.Free;

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,2k
    • Posts
      651,9k
×
×
  • Criar Novo...