以下代码错在哪里??预览时怎么没有啊??
procedure TForm1.QuickRepNeedData(Sender: TObject; var MoreData: Boolean);
var MyConst:Integer;
begin
//inc(fnum);
MoreData:=true;
for MyConst:=0 to list.Count-1 do
begin
While not QueryPrintVoucher.Eof do
begin
if QueryPrintVoucher.FieldByName('凭证号').AsInteger=strtoint(list.Strings[MyConst]) then
QRLabel4.Caption:= QueryPrintVoucher.FieldByName('科目名').AsString
else QRLabel4.Caption:= '000';
QueryPrintVoucher.Next;
end;
end;
MoreData:=false;
end;
解决方案 »
- spcomm控件的下载及安装?
- delphi操作memo填加删除数据库
- 发起最完美的Delphi VCL Unicode 兼容计划, 准备在sf.net开项目, 方案已定! 有经验的大虾请进!
- 为什么总会出现这样的错误????????????
- 怎样在dbgrid上选中某行,然后按ctrl+c(复制命令)把选取到的第一个字段内容复制
- [游戏修改器]怎么判断一个数据到了一个值后做一样事?
- 创建MTS/COM+的Windows SDK方法CoInitialize在什么单元中
- 怎样使一个窗体保持在所有MDIChild窗体之上,但不是stayontop ?
- 股票浏览软件请教,可能有高额好处!
- 如何清除listview所有内容
- 关于浮点运算错误的问题,请指教!!!!
- 求教这方面有经验的老兄帮帮忙
var MyConst:Integer;
begin
//inc(fnum);
MoreData:=true;
for MyConst:=0 to list.Count-1 do
begin
if QueryPrintVoucher.Eof then
QueryPrintVoucher.First;//加上这句看看
While not QueryPrintVoucher.Eof do
begin
if QueryPrintVoucher.FieldByName('凭证号').AsInteger=strtoint(list.Strings[MyConst]) then
QRLabel4.Caption:= QueryPrintVoucher.FieldByName('科目名').AsString
else QRLabel4.Caption:= '000';
QueryPrintVoucher.Next;
end;
end;
MoreData:=false;
end;
unit Unit2;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, QuickRpt, QRCtrls, ExtCtrls;type
TForm1 = class(TForm)
QuickRep1: TQuickRep;
DetailBand1: TQRBand;
QRLabel1: TQRLabel;
procedure QuickRep1NeedData(Sender: TObject; var MoreData: Boolean);
procedure QuickRep1BeforePrint(Sender: TCustomQuickRep;
var PrintReport: Boolean);
private
{ Private declarations }
MyConst:integer;
public
{ Public declarations }
end;var
Form1: TForm1;implementationuses mainwin;{$R *.dfm}procedure TForm1.QuickRep1NeedData(Sender: TObject; var MoreData: Boolean);
begin
if MyConst<F_main.memo1.lines.count-1 then
if F_main.ADOQuery4.Eof then
begin
inc(MyConst);
F_main.ADOQuery4.First;
end;
if not F_main.ADOQuery4.Eof then
MoreData:=true
else MoreData:=False;
if moredata then
begin
if MyConst<=F_main.memo1.lines.count-1 then
begin
if copy(F_main.ADOQuery4.FieldByName('id').Asstring,1,4)=F_main.memo1.lines[MyConst] then
QRLabel1.Caption:= F_main.ADOQuery4.FieldByName('name').AsString
else QRLabel1.Caption:= '000';
F_main.ADOQuery4.Next;
end;
end;
end;procedure TForm1.QuickRep1BeforePrint(Sender: TCustomQuickRep;
var PrintReport: Boolean);
begin
MyConst:=0;
end;end.
是什么意思??
if moredata then
begin
if MyConst<=list.count-1 then
begin
if QueryPrintVoucher.FieldByName('凭证号').AsInteger=strtoint(list.Strings[MyConst]) then
begin
QRLabel4.Caption:= QueryPrintVoucher.FieldByName('科目名').AsString;
t:=t+1;
end;
while t mod 6 <> 0 do
begin
QRLabel4.Caption:='000';
t:=t+1;
end;
t:=0;
QueryPrintVoucher.Next;
end;
end;
//t:=0;
if MyConst<list.count-1 then
begin
if QueryPrintVoucher.Eof then
begin
inc(MyConst);
QueryPrintVoucher.First;
end;
end; if not QueryPrintVoucher.Eof then
MoreData:=true
else MoreData:=False; if moredata then
begin
if MyConst<=list.count-1 then
begin
if QueryPrintVoucher.FieldByName('凭证号').AsInteger=strtoint(list.Strings[MyConst]) then
begin
QRLabel4.Caption:= QueryPrintVoucher.FieldByName('科目名').AsString;
QRLabel5.Caption:= inttostr(QueryPrintVoucher.FieldByName('凭证号').AsInteger);
t:=t+1;//为何不能自加呢???结果不正确阿. 怎么办??
QRLabel6.Caption:= '记录数['+inttostr(t)+']';
end; QueryPrintVoucher.Next;
end;
end;
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, QuickRpt, QRCtrls, ExtCtrls;type
TForm1 = class(TForm)
QuickRep1: TQuickRep;
DetailBand1: TQRBand;
QRLabel1: TQRLabel;
QRLabel2: TQRLabel;
procedure QuickRep1NeedData(Sender: TObject; var MoreData: Boolean);
procedure QuickRep1BeforePrint(Sender: TCustomQuickRep;
var PrintReport: Boolean);
procedure DetailBand1AfterPrint(Sender: TQRCustomBand;
BandPrinted: Boolean);
private
{ Private declarations }
MyConst,t:integer;
public
{ Public declarations }
end;var
Form1: TForm1;implementationuses mainwin;{$R *.dfm}procedure TForm1.QuickRep1NeedData(Sender: TObject; var MoreData: Boolean);
begin
if MyConst<F_main.memo1.lines.count-1 then
if F_main.ADOQuery4.Eof then
begin
inc(MyConst);
F_main.ADOQuery4.First;
end;
if not F_main.ADOQuery4.Eof then
MoreData:=true
else MoreData:=False;
if moredata then
begin
if MyConst<=F_main.memo1.lines.count-1 then
begin
if copy(F_main.ADOQuery4.FieldByName('id').Asstring,1,4)=F_main.memo1.lines[MyConst] then
begin
QRLabel1.Caption:= F_main.ADOQuery4.FieldByName('name').AsString; end
else QRLabel1.Caption:= '000';
t:=t+1;
QRLabel2.Caption:= '记录数['+inttostr(t)+']';
F_main.ADOQuery4.Next;
end;
end;
end;procedure TForm1.QuickRep1BeforePrint(Sender: TCustomQuickRep;
var PrintReport: Boolean);
begin
MyConst:=0;
t:=0;
end;//控制分页
procedure TForm1.DetailBand1AfterPrint(Sender: TQRCustomBand;
BandPrinted: Boolean);
begin
if t mod 6=0 then
QuickRep1.NewPage;
end;end.
在MOREDATA:=TRUE;后加
if QueryPrintVoucher.Eof then break;
把最后的MOREDATA:=FALSE该为:
if QueryPrintVoucher.Eof then MOREDATA:=TRUE;有用就给分。
unit Unit2;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, QuickRpt, QRCtrls, ExtCtrls;type
TForm1 = class(TForm)
QuickRep1: TQuickRep;
DetailBand1: TQRBand;
QRLabel1: TQRLabel;
QRLabel2: TQRLabel;
procedure QuickRep1NeedData(Sender: TObject; var MoreData: Boolean);
procedure QuickRep1BeforePrint(Sender: TCustomQuickRep;
var PrintReport: Boolean);
procedure DetailBand1AfterPrint(Sender: TQRCustomBand;
BandPrinted: Boolean);
private
{ Private declarations }
a,b:string;
t:integer;
public
{ Public declarations }
end;var
Form1: TForm1;implementationuses mainwin;{$R *.dfm}procedure TForm1.QuickRep1NeedData(Sender: TObject; var MoreData: Boolean);
begin
if not F_main.ADOQuery4.Eof then
MoreData:=true
else MoreData:=False;
b:=F_main.ADOQuery4.FieldByName('id').Asstring;
if moredata then
begin
if b=a then
begin
QRLabel1.Caption:= F_main.ADOQuery4.FieldByName('name').AsString;
t:=t+1;
QRLabel2.Caption:= '记录数['+inttostr(t)+']';
F_main.ADOQuery4.Next;
end else
begin
QRLabel1.Caption:='';
QRLabel2.Caption:='';
t:=t+1;
if t mod 6=0 then
a:=b;
end;
end;
end;procedure TForm1.QuickRep1BeforePrint(Sender: TCustomQuickRep;
var PrintReport: Boolean);
begin
a:= F_main.ADOQuery4.FieldByName('id').Asstring;
t:=0;
end;procedure TForm1.DetailBand1AfterPrint(Sender: TQRCustomBand;
BandPrinted: Boolean);
begin
if t mod 6=0 then
QuickRep1.NewPage;
end;end.
if copy(F_main.ADOQuery4.FieldByName('id').Asstring,1,4)=F_main.memo1.lines[MyConst] then
begin
QRLabel1.Caption:= F_main.ADOQuery4.FieldByName('name').AsString; end
else QRLabel1.Caption:= '000';
procedure TForm1.QuickRep1NeedData(Sender: TObject; var MoreData: Boolean);
begin
if not F_main.ADOQuery4.Eof then
MoreData:=true
else begin
if t mod 6<>0 then
begin
MoreData:=true;
t:=t+1;
end else MoreData:=False;
if MoreData then
begin
QRLabel1.Caption:='';
QRLabel2.Caption:='';
end;
Exit;
end;
b:=F_main.ADOQuery4.FieldByName('id').Asstring;
if moredata then
begin
if b=a then
begin
QRLabel1.Caption:= F_main.ADOQuery4.FieldByName('name').AsString;
QRLabel3.Caption:= F_main.ADOQuery4.FieldByName('a1').AsString;
t:=t+1;
QRLabel2.Caption:= '记录数['+inttostr(t)+']';
F_main.ADOQuery4.Next;
end else
begin //以空行补满
QRLabel1.Caption:='';
QRLabel2.Caption:='';
t:=t+1;
if t mod 6=0 then
a:=b;
end;
end;end;procedure TForm1.DetailBand1AfterPrint(Sender: TQRCustomBand;
BandPrinted: Boolean);
begin
if (t mod 6=0) and (not F_main.ADOQuery4.Eof) then
QuickRep1.NewPage; //每页6条记录
end;