不用SQL给打印记录编号

以QUICKREPORT为例

页面设置如下:

其中ID为编号。

设置为表的ID字段。

 

QUICKREPORT所在的FORM添加一个变量:

var
FprnT6: TFprnT6;
Vxh:integer; //编号变量

 

公开一个方法,用以设置变量的初始值:

public
{ Public declarations }
procedure Setxh(Axh:integer);

 

procedure TFprnT6.Setxh(Axh:integer);
begin
Vxh:=Axh;
end;

 

在ID的ONPRINT方法添加如下代码:
procedure TFprnT6.QRPDBText1Print(sender: TObject; var Value: string);
begin
Vxh:=Vxh+1;
Value:=inttostr(Vxh);
end;

 

 

控制打印主程序如下:


procedure TFCountMain.DoCountT6(Gtitle,GTdate:string);
var
sqlstr:string;
begin

Application.CreateForm(TFprnT6, FprnT6);
FprnT6.QRLtitle.Caption:=Gtitle;
FprnT6.QRLreportdate.Caption:=GTdate;
FprnT6.Setxh(0); //序号清零
sqlstr:='select * from Tperson ';
dm.LoadPersonBySql(sqlstr);//提取数据记录
FprnT6.QuickRep1.Print;

end;

 

posted @ 2014-12-03 07:48  happyhills  阅读(395)  评论(0编辑  收藏  举报