Eu executo o relatorio uma vez ai beleza, mas depois executa
mais outra vez dá esse erro:
Access violation at address 00404AA0 in module 'sistemacfc.exe'.Write of address 00000244.
Ai executo novamente e dá esse erro:
A component named QrSemanal already exists.
esse QrSemanal é o nome do meu relatório, sei que está muito grande
e já tentei varias maneiras para resolver mais nada, mas vou
passar todo o codigo fonte para alguém me ajudar..
procedure TfrmLisRelPraSemanais.spbexiClick(Sender: TObject);
begin
Application.CreateForm(TQrSemanal,QrSemanal);
// Coluna das Datas
for i:=1 to 7 do
begin
data := TQRLabel.Create(self);
with data do
begin
Name := 'Dat'+inttostr(i);
Left := -40+(i*135);
top := 50;
Frame.DrawTop := true;
Frame.DrawBottom := true;
Frame.DrawLeft := true;
Frame.DrawRight := true;
Transparent := true;
Width := 130;
Font.Size := 12;
Height := 21;
Font.Name := 'Arial';
Font.Style := [fsBold];
AutoSize := false;
Caption := DateToStr(DataInicial.Date-1 + i);
Alignment := TaCenter;
Parent := QrSemanal.QRBand1;
end;
end;
// coluna de horarios
for a:=1 to 16 do
begin
HorIni := TQRLabel.Create(self);
with HorIni do
begin
Name := 'Hor'+inttostr(a);
Left := 4;
Height := 22;
Frame.DrawTop := true;
Frame.DrawBottom := true;
Frame.DrawLeft := true;
Frame.DrawRight := true;
Transparent := true;
AutoSize := false;
Width := 43;
Font.Size := 10;
Font.Name := 'Arial';
Font.Style := [fsBold];
Caption := '';
Alignment := tacenter;
top := 50+(a*25);
Parent := QrSemanal.QRBand1;
end;
// end;
// coluna de horarios
// for HrF:=1 to 16 do
// begin
HorFin := TQRLabel.Create(self);
with HorFin do
begin
Name := 'HorFin'+inttostr(a);
Left := 50;
Height := 22;
Frame.DrawTop := true;
Frame.DrawBottom := true;
Frame.DrawLeft := true;
Frame.DrawRight := true;
Transparent := true;
AutoSize := false;
Width := 43;
Font.Size := 10;
Font.Name := 'Arial';
Font.Style := [fsBold];
Caption := '';
Alignment := tacenter;
top := 50+(a*25);
Parent := QrSemanal.QRBand1;
end;
end;
//criacao do QrLabel do Instrutor
begin
Inst := TQRLabel.Create(Self);
with Inst do
begin
Name := 'Ins';
Left := 104;
top := 480;
Frame.DrawTop := true;
Frame.DrawBottom := true;
Frame.DrawLeft := true;
Frame.DrawRight := true;
Transparent := true;
AutoSize := false;
Width := 300;
Font.Size := 12;
Font.Name := 'Arial';
Parent := QrSemanal.QRBand1;
end;
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);
with Aluno do
begin
Name := 'Al'+inttostr(soma);
Left := -40+(c*135);
top := 50+(b*25);
Frame.DrawTop := true;
Frame.DrawBottom := true;
Frame.DrawLeft := true;
Frame.DrawRight := true;
Transparent := true;
AutoSize := false;
Width := 130;
Font.Size := 9;
Height := 22;
Font.Name := 'Arial';
Font.Style := [fsBold];
Caption := '';
Parent := QrSemanal.QRBand1;
end;
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.Status, 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('Status').AsInteger = 0 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;
close;
end;
Pergunta
robinhocne
Eu executo o relatorio uma vez ai beleza, mas depois executa
mais outra vez dá esse erro:
Ai executo novamente e dá esse erro:
A component named QrSemanal already exists.
esse QrSemanal é o nome do meu relatório, sei que está muito grande
e já tentei varias maneiras para resolver mais nada, mas vou
passar todo o codigo fonte para alguém me ajudar..
procedure TfrmLisRelPraSemanais.spbexiClick(Sender: TObject); begin Application.CreateForm(TQrSemanal,QrSemanal); // Coluna das Datas for i:=1 to 7 do begin data := TQRLabel.Create(self); with data do begin Name := 'Dat'+inttostr(i); Left := -40+(i*135); top := 50; Frame.DrawTop := true; Frame.DrawBottom := true; Frame.DrawLeft := true; Frame.DrawRight := true; Transparent := true; Width := 130; Font.Size := 12; Height := 21; Font.Name := 'Arial'; Font.Style := [fsBold]; AutoSize := false; Caption := DateToStr(DataInicial.Date-1 + i); Alignment := TaCenter; Parent := QrSemanal.QRBand1; end; end; // coluna de horarios for a:=1 to 16 do begin HorIni := TQRLabel.Create(self); with HorIni do begin Name := 'Hor'+inttostr(a); Left := 4; Height := 22; Frame.DrawTop := true; Frame.DrawBottom := true; Frame.DrawLeft := true; Frame.DrawRight := true; Transparent := true; AutoSize := false; Width := 43; Font.Size := 10; Font.Name := 'Arial'; Font.Style := [fsBold]; Caption := ''; Alignment := tacenter; top := 50+(a*25); Parent := QrSemanal.QRBand1; end; // end; // coluna de horarios // for HrF:=1 to 16 do // begin HorFin := TQRLabel.Create(self); with HorFin do begin Name := 'HorFin'+inttostr(a); Left := 50; Height := 22; Frame.DrawTop := true; Frame.DrawBottom := true; Frame.DrawLeft := true; Frame.DrawRight := true; Transparent := true; AutoSize := false; Width := 43; Font.Size := 10; Font.Name := 'Arial'; Font.Style := [fsBold]; Caption := ''; Alignment := tacenter; top := 50+(a*25); Parent := QrSemanal.QRBand1; end; end; //criacao do QrLabel do Instrutor begin Inst := TQRLabel.Create(Self); with Inst do begin Name := 'Ins'; Left := 104; top := 480; Frame.DrawTop := true; Frame.DrawBottom := true; Frame.DrawLeft := true; Frame.DrawRight := true; Transparent := true; AutoSize := false; Width := 300; Font.Size := 12; Font.Name := 'Arial'; Parent := QrSemanal.QRBand1; end; 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); with Aluno do begin Name := 'Al'+inttostr(soma); Left := -40+(c*135); top := 50+(b*25); Frame.DrawTop := true; Frame.DrawBottom := true; Frame.DrawLeft := true; Frame.DrawRight := true; Transparent := true; AutoSize := false; Width := 130; Font.Size := 9; Height := 22; Font.Name := 'Arial'; Font.Style := [fsBold]; Caption := ''; Parent := QrSemanal.QRBand1; end; 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.Status, 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('Status').AsInteger = 0 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; close; end;Link para o comentário
Compartilhar em outros sites
7 respostass a esta questão
Posts Recomendados
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.