datareport到底怎么用?
我不知道该怎么用 我先在设计器里把Datareport 样子编辑好了 但没设置什么dataenviroment 更没绑定 我直接在窗口的一个按钮里 写这些代码 能实现打印么?
Private Sub Command4_Click()Set db = New ADODB.ConnectionSet rs = New ADODB.Recordsetdb.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=lzjc;Data Source=."db.Openrs.Open "select daA.购买人,daB.类别,daB.名称,daB.数量 ,round(kucun.进价/(1-(daA.利润+运输费)/daA.实收),1) as 单价, daB.数量*round(kucun.进价/(1-(daA.利润+运输费)/daA.实收),1) as 金额,(select 实收 from daA where id =(select max(id) from daA)) as 合计 from daB,kucun,daA where daB.名称=kucun.名称 and daA.id=daB.Aid and Aid=(select max(id) from daA)", db, adOpenStatic, adLockReadOnly Set DataReport1.DataSource = rs If rs.RecordCount = 0 Then Exit Sub End If With DataReport1 .Sections("Section1").Controls(Text5).DataField = rs.Fields("购买人").Value .Sections("Section1").Controls(Text1).DataField = rs.Fields("类别").Value .Sections("Section1").Controls(Text2).DataField = rs.Fields("名称").Value .Sections("Section1").Controls(Text3).DataField = rs.Fields("数量").Value .Sections("Section1").Controls(Text4).DataField = rs.Fields("单价").Value .Sections("Section1").Controls(Text4).DataField = rs.Fields("金额").Value .Sections("Section1").Controls(Text7).DataField = rs.Fields("合计").Value End With DataReport1.ShowEnd Sub