Erro na impressão do relatório

17/04/2013

0

Caro colegas,

Venho mais uma vez pedir a ajuda de vocês.
Estou com o seguinte problema:
Quando mando uma impressão utilizando o rvsystem e o relatório aparentemente grande, surge uma mensagem de violação ao endereço: "Access violation at address 00575CC3 in module 'MeuPrograma.exe'. Read of address 409F700.

Uso o comando para imprimir assim:

RvSystem1.SystemPrinter.MarginBottom := 1;
RvSystem1.SystemPrinter.MarginLeft := 0.8;
RvSystem1.SystemPrinter.MarginTop := 1;
RvSystem1.SystemPrinter.MarginBottom := 1;
RvSystem1.SystemPrinter.Units := unInch;
RvSystem1.SystemPrinter.UnitsFactor := 2.54;
RvSystem1.SystemPrinter.Orientation := poLandScape;
RvSystem1.SystemSetups :=[];
RvSystem1.Execute;

O RvsystemPrinter é assim, já fiz o debugg:
[Quote]
procedure TForm.RvSystem1Print(Sender: TObject);
Var Str, Aux, Descricao, Mes : String;
ValorOriginal, Correcao, InccPago, InccSaldo, Soma, Multa,
CJuros, CMulta, CProrata, Total, Juros, ProRata, Pagar, diferenca : Real;
I, J, A : Integer;
Matriz : array [1 .. 20, 1 .. 20] of Real;
Saldo : Variant;
begin
with RvSystem1.BaseReport do
Begin
Image := TBitmap.Create;
If FileExists(FormPrincipal.Caminho + '\Logomarca.bmp') Then
Begin
Image.LoadFromFile(FormPrincipal.Caminho + '\Logomarca.bmp');
PrintBitmapRect(1, 0.5, 19.5, 3, Image);
GotoXY(0.8,4.2);
end;
SetFont('Courier New',8);
InccSaldo := ceValorContrato.Value / ceINCCBase.Value;
Println('Edifício...: '+cePredio.Text+'-'+stPredio.Caption);
NewLine;
Println('Apartamento Num.: '+AcrescEspaco(ceApto.Text,10,'D') + ' Valor Apt: '+
AcrescEspaco(Formatar_valores(ceValorContrato.Value),10,'E'));
Println('Data do contrato: '+deDataContrato.Text + ' INCC Base: '+
AcrescEspaco(Formatar_valores(ceINCCBase.Value),10,'E') +
' Total INCC do contrato: ' + FormatFloat('0.0000',InccSaldo));
println('Proprietário....: '+ceCliente.Text);
Println('Fone............: '+AchaC[2]+' '+AchaC[3]+' '+AchaC[4]);
If cbVendedor.Checked Then
Begin
Println('Vendedor 1...: '+AcrescEspaco(stVend1.Caption,20,'D')+
' Comissão: '+AcrescEspaco(Formatar_valores(ceComissaoVenda.Value),5,'E')+'% '+
'Data Pgto Com: '+deDataPgtoComissao.Text +
' Valor Pago: ' + AcrescEspaco(Formatar_valores(ceValorComissao.Value),10,'E'));

Println('Vendedor 2...: '+AcrescEspaco(stVend2.Caption,20,'D')+
' Comissão: ' + AcrescEspaco(Formatar_valores(ceComissaoAtingido.Value),5,'E')+'% '+
'Data Pgto Com: '+deDataPgoAtingido.Text +
' Valor Pago: ' +AcrescEspaco(Formatar_valores(ceValorAtingido.Value),10,'E'));
end;
println(RepeteChar('=',153));
println('INCC/ MES EVENTO VENCTO VALOR CORREÇAO MULTA Nº DIAS CORREÇAO Juros Valor Valor Data');
Println('IGPM ORIGINAL Atraso Pró-rata die 1% Mes A Pagar Pago Pagto');
println(RepeteChar('-',153));
cdsMovimento.IndexFieldNames := 'Vencto';
cdsMovimento.First;
J := 0;
Multa := 0;
InccPago := 0;
Soma := 0;
Correcao := 0;
ValorOriginal := 0;
Juros := 0;
Diferenca := 0;
ProRata := 0;
Pagar := 0;
A := 0;
While Not cdsMovimento.Eof do
Begin
if LinesLeft = 0 Then
Begin
println('Continua...'+RepeteChar('-',142));
NewPage;
SetFont('Arial',10);
SetFont('Courier New',8);
If FileExists(FormPrincipal.Caminho + '\Logomarca.bmp') Then
Begin
PrintBitmapRect(1, 0.5, 19.5, 3, Image);
GotoXY(0.8,4.2);
end;
SetFont('Courier New',8);
println(RepeteChar('=',153));
println('INCC/ MES EVENTO VENCTO VALOR CORREÇAO MULTA Nº DIAS CORREÇAO Juros Valor Valor Data');
Println('IGPM ORIGINAL Atraso Pró-rata die 1% Mes A Pagar Pago Pagto');
println(RepeteChar('-',153));
end;
case rbOpcoes.ItemIndex of
0 : Begin
if cdsMovimentoVALORPAGO.AsFloat = 0 Then
Begin
cdsMovimento.Next;
Continue;
end;
if (cdsMovimentoDATAPAGTO.AsDateTime < deInicial.Date) or
(cdsMovimentoDATAPAGTO.AsDateTime > deFinal.Date) Then
Begin
cdsMovimento.Next;
Continue;
end;
end;
1 : Begin
if cdsMovimentoVALORPAGO.AsFloat <> 0 Then
Begin
cdsMovimento.Next;
Continue;
end;
if (cdsMovimentoVENCTO.AsDateTime < deInicial.Date) or
(cdsMovimentoVALORORIGINAL.AsDateTime > deFinal.Date) Then
Begin
cdsMovimento.Next;
Continue;
end;
end;
2: Begin
if (cdsMovimentoVENCTO.AsDateTime < deInicial.Date) or
(cdsMovimentoVENCTO.AsDateTime > deFinal.Date) Then
Begin
cdsMovimento.Next;
Continue;
end;
end;
3 : Begin
if cdsMovimentoVALORPAGO.AsFloat = 0 Then
Begin
cdsMovimento.Next;
Continue;
end;
end;
4 : Begin
if cdsMovimentoVALORPAGO.AsFloat <> 0 Then
Begin
cdsMovimento.Next;
Continue;
end;
end;
end;
AchaEvento(cdsMovimentoEVENTO.AsString);
Descricao := AchaEv[1];
If (j <> YearOf(cdsMovimentoDATAPAGTO.AsDateTime)) and (cdsMovimentoVALORPAGO.AsFloat > 0) Then
Begin
j := YearOf(cdsMovimentoDATAPAGTO.AsDateTime);
Inc(A);
end;
Mes := data_incc(cdsMovimentoVENCTO.AsDateTime);
Str := AcrescEspaco(Formatar_valores(cdsMovimentoINCC.AsFloat),10,'E')+' '+
Mes +' '+
AcrescEspaco(Descricao,20,'D')+' '+
formataData(cdsMovimentoVENCTO.AsDateTime)+ ' ' +
AcrescEspaco(Formatar_valores(cdsMovimentoVALORORIGINAL.AsFloat),10,'E')+' ';


If cdsMovimentoVALORPAGO.AsFloat > 0 Then
Begin
Total := cdsMovimentoVALORORIGINAL.AsFloat+
cdsMovimentoCORRECAO.AsFloat +
cdsMovimentoMULTA.AsFloat +
cdsMovimentoMULTAPRORATA.AsFloat;
Str := Str + AcrescEspaco(Formatar_valores(cdsMovimentoCORRECAO.AsFloat),10,'E')+' ';
end
Else if Echaves Then
Begin
Busca_INCC(Now, Echaves,StrToInt(stContrato.caption));
If AchaEv[2]='1' Then
Begin
If Incc[1] <> 0 Then
Total := ((cdsMovimentoVALORORIGINAL.AsFloat / ceINCCBase.Value * INCC[0]) * Incc[1])
else
Total := (cdsMovimentoVALORORIGINAL.AsFloat + cdsMovimentoINCC.AsFloat) * INCC[0]
end
Else
Total := cdsMovimentoVALORORIGINAL.AsFloat;
end
Else
Begin
If AchaEv[2]='1' Then
Total := cdsMovimentoVALORORIGINAL.AsFloat+
cdsMovimentoINCC.AsFloat +
cdsMovimentoMULTA.AsFloat +
cdsMovimentoMULTAPRORATA.AsFloat
Else
Total := cdsMovimentoVALORORIGINAL.AsFloat+
cdsMovimentoMULTA.AsFloat +
cdsMovimentoMULTAPRORATA.AsFloat;
end;

If cdsMovimentoVALORPAGO.AsFloat <> 0 Then
Begin
CMulta := cdsMovimentoMULTA.AsFloat;
Str := Str + AcrescEspaco(Formatar_valores(CMulta),10,'E')+' ';
CJuros := cdsMovimentoJUROS.AsFloat;
CProrata := cdsMovimentoMULTAPRORATA.AsFloat;
Str := Str + AcrescEspaco(PrazoDecorridos(cdsMovimentoVENCTO.AsDateTime,cdsMovimentoDATAPAGTO.AsDateTime),8,'E')+' ';
Aux := formataData(cdsMovimentoDATAPAGTO.AsDateTime);
end
Else
Begin
CMulta := 0;
CJuros := 0;
CProrata:= 0;
If StrToFloat(PrazoDecorridos(cdsMovimentoVENCTO.AsDateTime,Now)) > 0 Then
Begin
if cbJuros.Checked Then
Begin
ceCorrecao.Value := Total - cdsMovimentoVALORORIGINAL.AsFloat;
CProrata := (ceCorrecao.Value / StrToFloat(PrazoDecorridos(deDataContrato.Date,Now)) *
StrToFloat(PrazoDecorridos(cdsMovimentoVENCTO.AsDateTime,Now)));
CMulta := (cdsMovimentoVALORORIGINAL.AsFloat + CProrata)*0.02;
CJuros := ((ceAPAGAR.Value + CProrata) * 0.000333333) * StrToFloat(PrazoDecorridos(cdsMovimentoVENCTO.AsDateTime,Now));
Total := Total + CJuros + CProrata + CMulta;
end
Else
ceCorrecao.Value := Total - cdsMovimentoVALORORIGINAL.AsFloat;;
end;
Str := Str + AcrescEspaco(Formatar_valores(ceCorrecao.Value),10,'E')+' ';
Str := Str + AcrescEspaco(Formatar_valores(CMulta),10,'E')+' ';
Str := Str + RepeteChar(' ',9);
Aux := ''
end;
println( Str +
AcrescEspaco(Formatar_valores(CProrata),10,'E')+' '+
AcrescEspaco(Formatar_valores(CJuros),10,'E')+' '+
AcrescEspaco(Formatar_valores(Total),10,'E')+' '+
AcrescEspaco(Formatar_valores(cdsMovimentoVALORPAGO.AsFloat),10,'E')+
' '+Aux);
Juros := Juros + CJuros;
Diferenca := Diferenca + (Total - cdsMovimentoVALORPAGO.AsFloat);
ProRata := ProRata + CProrata;
Pagar := Pagar + Total;
Soma := Soma + cdsMovimentoVALORPAGO.AsFloat;
InccPago := InccPago + (cdsMovimentoVALORORIGINAL.AsFloat / ceINCCBase.Value);
ValorOriginal := ValorOriginal + cdsMovimentoVALORORIGINAL.AsFloat;
Correcao := Correcao + cdsMovimentoCORRECAO.AsFloat;
Multa := Multa + CMulta;
Matriz[A,1] := j;
Matriz[A,2] := Matriz[A,2] + cdsMovimentoVALORPAGO.AsFloat;
cdsMovimento.Next;
end;
println(RepeteChar('-',153));
Aux :=
'TOTAIS DO PERIODO: ' + RepeteChar(' ',35) +
AcrescEspaco(Formatar_valores(ValorOriginal),10,'E') + ' ' +
AcrescEspaco(Formatar_valores(Correcao),10,'E') + ' ' +
AcrescEspaco(Formatar_valores(Multa),10,'E') +
RepeteChar(' ',10) +
AcrescEspaco(Formatar_valores(ProRata),10,'E') + ' ' +
AcrescEspaco(Formatar_valores(Juros),10,'E') + ' ' +
AcrescEspaco(Formatar_valores(Pagar),10,'E') + ' ' +
AcrescEspaco(Formatar_valores(Soma),10,'E');
Pula_Pagina; Println(Aux);
Pula_Pagina; Println(RepeteChar(' ',106) + 'TOTAL PAGO: ' +
AcrescEspaco(Formatar_valores(Soma),10,'E'));
Pula_Pagina; Println(RepeteChar(' ',103) + 'TOTAL A PAGAR: ' +
AcrescEspaco(Formatar_valores(Pagar-Soma),10,'E'));
NewLine;
Saldo := EncontraValor('Select Incc_pago, Incc_Pagar '+
'From Valores_Recebidos(:0,'+QuotedStr(FormatDateTime('dd.mm.yyyy',FormPrincipal.deDataCalculo.Date))+')',stContrato.Caption);
Pula_Pagina;
If Echaves Then
Begin
SetFont('Courier New',12);
Bold := True;
FontColor := clRed;
PrintLn('Devedor em R$...: '+ AcrescEspaco(Formatar_valores(ceTotalPagar.Value),10,'E'));
Bold := False;
FontColor := clBlack;
SetFont('Courier New',8); Pula_Pagina;
Println('Total Pago R$...: '+AcrescEspaco(Formatar_valores(Soma),14,'E'));
Pula_Pagina;
Println('INCC Pago.......: '+AcrescEspaco(FormatFloat('0.0000',Saldo[0]),14,'E'));
Pula_Pagina;
If cbFormula.checked Then
begin
SetFont('Courier New',6);
PrintLn('Formula para o Saldo Devedor:'); Pula_Pagina;
PrintLn('Saldo Devedor = (Valor Original Corrigido) * (Indice IGPM Atual/IGPM mes Anterior) * 0.94 ');
PrintLn('Saldo Devedor = ('+AcrescEspaco(stINCCApagar.Caption,14,'E') +
' ) * ' + VarToStr(INCC[0]));
SetFont('Courier New',8);
end;
Pula_Pagina;

end
else
Println('INCC Pago....: '+AcrescEspaco(FormatFloat('0.0000',InccPago),14,'E') +
' Saldo devedor: '+AcrescEspaco(stINCCApagar.Caption,14,'E') +
' X Incc Atual ' + VarToStr(INCC[0]) +
' = Devedor em R$ = ' + AcrescEspaco(Formatar_valores(ceTotalPagar.Value),10,'E'));
NewLine;
If cbAnoAno.Checked Then
begin
Aux := RepeteChar(' ',20);
bold := True;
Pula_Pagina;
Println(AUX + ' RESUMO DE PAGAMENTO ANUAL');
bold := False;
Pula_Pagina;
Println(Aux + '+================================+');
Pula_Pagina;
Println(Aux + '| ANO | VALOR RECEBIDO |');
Pula_Pagina;
Println(Aux + '|================================|');
For i := 1 to A do
begin
Pula_Pagina;
Println(Aux + '| ' + FloatToStr(Matriz[i,1])+
' | ' + AcrescEspaco(Formatar_valores(Matriz[i,2]),12,'E')+
' |');
end;
Pula_Pagina;
Println(Aux + '+================================+');
end;
NewLine;
Println('Impresso em: '+formataData(Now)+' '+FormataHora(Now));
end;
end;
[/Quote]

Só estou usando o componente RvSystem. Delphi 7.
Lembrando que, quando é poucas páginas dá certo.
Já tentei fazer em outro computador.

Desde já agradeço.
Dirceu Morais

Dirceu Morais

Responder

Posts

17/04/2013

Joel Rodrigues

Em que linha ocorre o erro?
Responder

17/04/2013

Dirceu Morais

Boa Noite,

O erro ocorre quando vai mostrar na tela/impressora, ou seja, independe eu colocar para mostrar no video

RvSystem1.SystemSetups :=[];
RvSystem1.Execute


ou mandar pra impressora direto


RvSystem1.SystemSetups := [];
RvSystem1.DefaultDest := rdPrinter;
RvSystem1.Execute;


Responder

18/04/2013

Dirceu Morais

O relatório que estou tentando imprimir e que dá o erro, tem umas 9 páginas.
Se eu filtrar o relatório colocando ele pra 4 páginas não dá o erro.

Será problema de memória? O fazer? Preciso desse relatório para o cliente fazer a declaração do imposto de renda!

Desde já agradeço
Responder

19/04/2013

Dirceu Morais

Aumentei o tamanho da minha matriz e funfou
procedure TForm.RvSystem1Print(Sender: TObject);
.
..
Matriz : array [1 .. 20, 1 .. 20] of Real;
...


Matriz : array [1 .. 72, 1 .. 72] of Real;
Responder

19/04/2013

Dirceu Morais

Aumentei o tamanho da minha matriz e funfou
procedure TForm.RvSystem1Print(Sender: TObject);
.
..
Matriz : array [1 .. 20, 1 .. 20] of Real;
...


Matriz : array [1 .. 72, 1 .. 72] of Real;
Responder

Que tal ter acesso a um e-book gratuito que vai te ajudar muito nesse momento decisivo?

Ver ebook

Recomendado pra quem ainda não iniciou o estudos.

Eu quero
Ver ebook

Recomendado para quem está passando por dificuldades nessa etapa inicial

Eu quero

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar