报表分类统计(200分)

  • 主题发起人 主题发起人 zymnm
  • 开始时间 开始时间
Z

zymnm

Unregistered / Unconfirmed
GUEST, unregistred user!
我做了一个小测试在form1上放一个button
procedure TForm1.Button1Click(Sender: TObject);
begin
form2.ADOQuery1.Active:=true;
form2.QuickRep1.Preview;
end;
在form2上放一个quickrep
DetailBand1: TQRBand;
QRGroup1: TQRGroup;
QRBand1: TQRBand;
sql语句用Northwind(SELECT *
FROM [Order Details]
WHERE (ProductID = '77') OR
(ProductID = '53')
order by ProductID
)想得到
orderid productid quantity
10256 53 15
10285 53 36
. . .
. . .
-----------------------------
合计 (203) //sunm(quantity)
orderid productid quantity
10261 77 20
10274 77 45
. . .
. . .
-----------------------------
合计 (274) //sunm(quantity)
 
有几个你确定一下:
1、Tform1是否已经引用了form2所在的单元
2、你在这个方法里没有创建from2这个窗体,你在哪创建他(这是必须的)
procedure Tfmspcgsh.SpeedButton1Click(Sender: TObject);
begin
form4.QuickRep1.Preview
end;
3、QuickRep1的DATASET属性你设置了么,而且是否在Preview前,DATASET有数据
4、前三点没问题了理论上不应该有错
5、我给你一点步骤(是在前三点没问题的基础上):
步骤:
1、quickrpt属性:
QuickRep1.Bands.HasColumnHeader:=true;
QuickRep1.Bands.HasDetail:=true;
QuickRep1.Bands.HasSummary:=true;
2、加控件
qrgroup,qrband
属性设置 qrgroup.footerband:=qrband
qrband.bandtype:=rbGroupFooter
qrgroup.expression:=你的分组字段(多字段要建立多个qrgroup)
3、在qrband加:qrlabel1,qrexpr
qrexpr1.expression:=sum(你的小计字段)
qrexpr1.resetAfterPrint:=true;
4、在summaryband加:qrlabel(合计),qrexpr2
qrexpr2.expression:=sum(你的合计字段)
qrexpr2.resetAfterPrint:=false;
注意:以上属性设置大多不要写代码,直接设置就行了
 
上面都做了,但是还是没有效果出来
label
10256 53 15
10285 53 36
10306 53 10
10312 53 20
10380 53 20
10388 53 40
10395 53 70
10416 53 10
10421 53 15
10437 53 15
10455 53 50
10479 53 28
10502 53 6
10504 53 10
10520 53 5
10558 53 18
10573 53 25
10626 53 12
10650 53 25
10675 53 10
10711 53 120
10712 53 3
10825 53 20
10833 53 9
10867 53 3
10933 53 2
10962 53 20
11033 53 70
11062 53 10
11064 53 25
10256 77 12
10257 77 15
10290 77 10
10366 77 5
10367 77 7
10399 77 14
10417 77 35
10421 77 10
10451 77 55
10483 77 30
10491 77 7
10495 77 5
10497 77 25
10554 77 10
10577 77 18
10587 77 20
10590 77 60
10602 77 5
10646 77 35
10658 77 70
10690 77 30
10735 77 2
10780 77 15
10812 77 20
10823 77 15
10835 77 2
10841 77 15
10885 77 25
10886 77 40
10929 77 15
10946 77 40
10986 77 15
10999 77 21
11000 77 30
11015 77 18
11060 77 10
11068 77 28
11077 77 2
合计 : 1513
 
除了qrexpr1.resetAfterPrint:=true;还要有什么注意点
 
是因为groupheader没有写
 
后退
顶部