我用QR做报表。现在我出来的报表就是一页到底,不会自己换页。我设过强制换页了,不行。
原代码如下。我想可能是循环上的问题。不知道怎么办好。
procedure Tqrpt_ysmx.beforepreview;
var
i:integer;
atop:integer;
aLabel:TQRLabel;
aLine:TQRShape;
d1,d2,d3:Tdate;
kh1:string;
begin
atop:=68;
d1:=ysquanbucx.date1;
d2:=ysquanbucx.date2;
kh1:=ysquanbucx.kh; qdate.Active:=false;
qdate.SQL.Clear;
qdate.SQL.Add('select 日期 from 应收明细');
qdate.SQL.Add('where 客户='''+kh1+''' and 日期>=#'+datetostr(d1) +'# and 日期<=#'+datetostr(d2) +'# group by 日期');
qdate.Prepared;
qdate.open; while not qdate.Eof do
begin
aLine:= TQRShape.Create(qrpt_ysmx);
aLine.Parent := TitleBand1;
with aLine do
begin
aLine.Left:=0;
aLine.Top:=atop;
aLine.Width:=1;
aLine.Height:=16;
aLine.Frame.Color:=clBlack;
end; aLabel:= TQRLabel.Create(qrpt_ysmx);
aLabel.Parent := TitleBand1;
with aLabel do
begin
AutoSize:=true;
AutoStretch:=True;
Font.Size:=8;
Left :=8;
Top := atop+2;
Alignment:=taLeftJustify;
d3:=qdate.Fields[0].Value;
Caption :=datetostr(d3);
end; qmingxi.Active:=false;
qmingxi.SQL.Clear;
qmingxi.SQL.Add('select 部门,摘要,增加费,减少费 from 应收明细');
qmingxi.SQL.Add('where 客户='''+kh1+''' and 日期=#'+datetostr(d3)+'# order by 部门');
qmingxi.Prepared;
qmingxi.open; while not qmingxi.Eof do
begin aLine:= TQRShape.Create(qrpt_ysmx);
aLine.Parent := TitleBand1;
with aLine do
begin
aLine.Left:=66;
aLine.Top:=atop;
aLine.Width:=1;
aLine.Height:=16;
aLine.Frame.Color:=clBlack;
end;
aLine:= TQRShape.Create(qrpt_ysmx);
aLine.Parent := TitleBand1;
with aLine do
begin
aLine.Left:=0;
aLine.Top:=atop;
aLine.Width:=1;
aLine.Height:=16;
aLine.Frame.Color:=clBlack;
end;
aLabel:= TQRLabel.Create(qrpt_ysmx);
aLabel.Parent := TitleBand1;
with aLabel do
begin
AutoSize:=true;
AutoStretch:=True;
Font.Size:=8;
Left :=75;
Top := atop+2;
Alignment:=taLeftJustify;
Caption:=qmingxi.Fields[0].Value;
end; aLine:= TQRShape.Create(qrpt_ysmx);
aLine.Parent := TitleBand1;
with aLine do
begin
aLine.Left:=125;
aLine.Top:=atop;
aLine.Width:=1;
aLine.Height:=16;
aLine.Frame.Color:=clBlack;
end; aLabel:= TQRLabel.Create(qrpt_ysmx);
aLabel.Parent := TitleBand1;
with aLabel do
begin
//AutoSize:=;
AutoStretch:=True;
Font.Size:=8;
Left :=130;
Top := atop+2;
Alignment:=taLeftJustify;
Caption :=qmingxi.Fields[1].Value;
end; aLine:= TQRShape.Create(qrpt_ysmx);
aLine.Parent := TitleBand1;
with aLine do
begin
aLine.Left:=433;
aLine.Top:=atop;
aLine.Width:=1;
aLine.Height:=16;
aLine.Frame.Color:=clBlack;
end; aLabel:= TQRLabel.Create(qrpt_ysmx);
aLabel.Parent := TitleBand1;
with aLabel do
begin
AutoSize:=true;
AutoStretch:=True;
Font.Size:=8;
Left :=437;
Top := atop+2;
Alignment:=taLeftJustify;
Caption :=qmingxi.Fields[2].asstring;
end; aLine:= TQRShape.Create(qrpt_ysmx);
aLine.Parent := TitleBand1;
with aLine do
begin
aLine.Left:=527;
aLine.Top:=atop;
aLine.Width:=1;
aLine.Height:=16;
aLine.Frame.Color:=clBlack;
end; aLabel:= TQRLabel.Create(qrpt_ysmx);
aLabel.Parent := TitleBand1;
with aLabel do
begin
AutoSize:=true;
AutoStretch:=True;
Font.Size:=8;
Left :=531;
Top := atop+2;
Alignment:=taLeftJustify;
Caption :=qmingxi.Fields[3].AsString;
end; aLine:= TQRShape.Create(qrpt_ysmx);
aLine.Parent := TitleBand1;
with aLine do
begin
aLine.Left:=619;
aLine.Top:=atop;
aLine.Width:=1;
aLine.Height:=16;
aLine.Frame.Color:=clBlack;
end; aLine:= TQRShape.Create(qrpt_ysmx);
aLine.Parent := TitleBand1;
with aLine do
begin
aLine.Left:=717;
aLine.Top:=atop;
aLine.Width:=1;
aLine.Height:=16;
aLine.Frame.Color:=clBlack;
end; aLine:= TQRShape.Create(qrpt_ysmx);
aLine.Parent := TitleBand1;
with aLine do
begin
aLine.Left:=0;
aLine.Top:=atop+16;
aLine.Width:=718;
aLine.Height:=1;
aLine.Frame.Color:=clBlack;
end; atop:=atop+16;
qmingxi.Next;
end;
qyue.Active:=false;
qyue.SQL.Clear;
qyue.SQL.Add('select sum(结存)as b1 from 应收结存');
qyue.SQL.Add('where (日期=#'+datetostr(d3) +'#) and (客户='''+kh1+''') and (结存<>0)');
qyue.Prepared;
qyue.Open;
// showmessage(datetostr(d3));
// showmessage(qyue.Fields[0].AsString); aLine:= TQRShape.Create(qrpt_ysmx);
aLine.Parent := TitleBand1;
with aLine do
begin
aLine.Left:=0;
aLine.Top:=atop;
aLine.Width:=1;
aLine.Height:=17;
aLine.Frame.Color:=clBlack;
end; aLine:= TQRShape.Create(qrpt_ysmx);
aLine.Parent := TitleBand1;
with aLine do
begin
aLine.Left:=619;
aLine.Top:=atop;
aLine.Width:=1;
aLine.Height:=17;
aLine.Frame.Color:=clBlack;
end; aLabel:= TQRLabel.Create(qrpt_ysmx);
aLabel.Parent := TitleBand1;
with aLabel do
begin
AutoSize:=true;
AutoStretch:=True;
Font.Size:=8;
Left :=628;
Top := atop+2;
Font.Style:=[fsBold];
Alignment:=taLeftJustify;
Caption:=qyue.Fields[0].AsString;
end; aLine:= TQRShape.Create(qrpt_ysmx);
aLine.Parent := TitleBand1;
with aLine do
begin
aLine.Left:=0;
aLine.Top:=atop+16;
aLine.Width:=718;
aLine.Height:=1;
aLine.Frame.Color:=clBlack;
end; aLine:= TQRShape.Create(qrpt_ysmx);
aLine.Parent := TitleBand1;
with aLine do
begin
aLine.Left:=717;
aLine.Top:=atop;
aLine.Width:=1;
aLine.Height:=17;
aLine.Frame.Color:=clBlack;
end; atop:=atop+16;
qdate.Next; end;
end;
end.
原代码如下。我想可能是循环上的问题。不知道怎么办好。
procedure Tqrpt_ysmx.beforepreview;
var
i:integer;
atop:integer;
aLabel:TQRLabel;
aLine:TQRShape;
d1,d2,d3:Tdate;
kh1:string;
begin
atop:=68;
d1:=ysquanbucx.date1;
d2:=ysquanbucx.date2;
kh1:=ysquanbucx.kh; qdate.Active:=false;
qdate.SQL.Clear;
qdate.SQL.Add('select 日期 from 应收明细');
qdate.SQL.Add('where 客户='''+kh1+''' and 日期>=#'+datetostr(d1) +'# and 日期<=#'+datetostr(d2) +'# group by 日期');
qdate.Prepared;
qdate.open; while not qdate.Eof do
begin
aLine:= TQRShape.Create(qrpt_ysmx);
aLine.Parent := TitleBand1;
with aLine do
begin
aLine.Left:=0;
aLine.Top:=atop;
aLine.Width:=1;
aLine.Height:=16;
aLine.Frame.Color:=clBlack;
end; aLabel:= TQRLabel.Create(qrpt_ysmx);
aLabel.Parent := TitleBand1;
with aLabel do
begin
AutoSize:=true;
AutoStretch:=True;
Font.Size:=8;
Left :=8;
Top := atop+2;
Alignment:=taLeftJustify;
d3:=qdate.Fields[0].Value;
Caption :=datetostr(d3);
end; qmingxi.Active:=false;
qmingxi.SQL.Clear;
qmingxi.SQL.Add('select 部门,摘要,增加费,减少费 from 应收明细');
qmingxi.SQL.Add('where 客户='''+kh1+''' and 日期=#'+datetostr(d3)+'# order by 部门');
qmingxi.Prepared;
qmingxi.open; while not qmingxi.Eof do
begin aLine:= TQRShape.Create(qrpt_ysmx);
aLine.Parent := TitleBand1;
with aLine do
begin
aLine.Left:=66;
aLine.Top:=atop;
aLine.Width:=1;
aLine.Height:=16;
aLine.Frame.Color:=clBlack;
end;
aLine:= TQRShape.Create(qrpt_ysmx);
aLine.Parent := TitleBand1;
with aLine do
begin
aLine.Left:=0;
aLine.Top:=atop;
aLine.Width:=1;
aLine.Height:=16;
aLine.Frame.Color:=clBlack;
end;
aLabel:= TQRLabel.Create(qrpt_ysmx);
aLabel.Parent := TitleBand1;
with aLabel do
begin
AutoSize:=true;
AutoStretch:=True;
Font.Size:=8;
Left :=75;
Top := atop+2;
Alignment:=taLeftJustify;
Caption:=qmingxi.Fields[0].Value;
end; aLine:= TQRShape.Create(qrpt_ysmx);
aLine.Parent := TitleBand1;
with aLine do
begin
aLine.Left:=125;
aLine.Top:=atop;
aLine.Width:=1;
aLine.Height:=16;
aLine.Frame.Color:=clBlack;
end; aLabel:= TQRLabel.Create(qrpt_ysmx);
aLabel.Parent := TitleBand1;
with aLabel do
begin
//AutoSize:=;
AutoStretch:=True;
Font.Size:=8;
Left :=130;
Top := atop+2;
Alignment:=taLeftJustify;
Caption :=qmingxi.Fields[1].Value;
end; aLine:= TQRShape.Create(qrpt_ysmx);
aLine.Parent := TitleBand1;
with aLine do
begin
aLine.Left:=433;
aLine.Top:=atop;
aLine.Width:=1;
aLine.Height:=16;
aLine.Frame.Color:=clBlack;
end; aLabel:= TQRLabel.Create(qrpt_ysmx);
aLabel.Parent := TitleBand1;
with aLabel do
begin
AutoSize:=true;
AutoStretch:=True;
Font.Size:=8;
Left :=437;
Top := atop+2;
Alignment:=taLeftJustify;
Caption :=qmingxi.Fields[2].asstring;
end; aLine:= TQRShape.Create(qrpt_ysmx);
aLine.Parent := TitleBand1;
with aLine do
begin
aLine.Left:=527;
aLine.Top:=atop;
aLine.Width:=1;
aLine.Height:=16;
aLine.Frame.Color:=clBlack;
end; aLabel:= TQRLabel.Create(qrpt_ysmx);
aLabel.Parent := TitleBand1;
with aLabel do
begin
AutoSize:=true;
AutoStretch:=True;
Font.Size:=8;
Left :=531;
Top := atop+2;
Alignment:=taLeftJustify;
Caption :=qmingxi.Fields[3].AsString;
end; aLine:= TQRShape.Create(qrpt_ysmx);
aLine.Parent := TitleBand1;
with aLine do
begin
aLine.Left:=619;
aLine.Top:=atop;
aLine.Width:=1;
aLine.Height:=16;
aLine.Frame.Color:=clBlack;
end; aLine:= TQRShape.Create(qrpt_ysmx);
aLine.Parent := TitleBand1;
with aLine do
begin
aLine.Left:=717;
aLine.Top:=atop;
aLine.Width:=1;
aLine.Height:=16;
aLine.Frame.Color:=clBlack;
end; aLine:= TQRShape.Create(qrpt_ysmx);
aLine.Parent := TitleBand1;
with aLine do
begin
aLine.Left:=0;
aLine.Top:=atop+16;
aLine.Width:=718;
aLine.Height:=1;
aLine.Frame.Color:=clBlack;
end; atop:=atop+16;
qmingxi.Next;
end;
qyue.Active:=false;
qyue.SQL.Clear;
qyue.SQL.Add('select sum(结存)as b1 from 应收结存');
qyue.SQL.Add('where (日期=#'+datetostr(d3) +'#) and (客户='''+kh1+''') and (结存<>0)');
qyue.Prepared;
qyue.Open;
// showmessage(datetostr(d3));
// showmessage(qyue.Fields[0].AsString); aLine:= TQRShape.Create(qrpt_ysmx);
aLine.Parent := TitleBand1;
with aLine do
begin
aLine.Left:=0;
aLine.Top:=atop;
aLine.Width:=1;
aLine.Height:=17;
aLine.Frame.Color:=clBlack;
end; aLine:= TQRShape.Create(qrpt_ysmx);
aLine.Parent := TitleBand1;
with aLine do
begin
aLine.Left:=619;
aLine.Top:=atop;
aLine.Width:=1;
aLine.Height:=17;
aLine.Frame.Color:=clBlack;
end; aLabel:= TQRLabel.Create(qrpt_ysmx);
aLabel.Parent := TitleBand1;
with aLabel do
begin
AutoSize:=true;
AutoStretch:=True;
Font.Size:=8;
Left :=628;
Top := atop+2;
Font.Style:=[fsBold];
Alignment:=taLeftJustify;
Caption:=qyue.Fields[0].AsString;
end; aLine:= TQRShape.Create(qrpt_ysmx);
aLine.Parent := TitleBand1;
with aLine do
begin
aLine.Left:=0;
aLine.Top:=atop+16;
aLine.Width:=718;
aLine.Height:=1;
aLine.Frame.Color:=clBlack;
end; aLine:= TQRShape.Create(qrpt_ysmx);
aLine.Parent := TitleBand1;
with aLine do
begin
aLine.Left:=717;
aLine.Top:=atop;
aLine.Width:=1;
aLine.Height:=17;
aLine.Frame.Color:=clBlack;
end; atop:=atop+16;
qdate.Next; end;
end;
end.
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货