水晶报表的问题,总是出现重复的记录,N条重复N次。
Dim crApp As New CRAXDRT.ApplicationDim crRpt As New CRAXDRT.Report
Dim nd As String
nd = Text1.Text
Dim conn1 As ADODB.Connection
Dim rs1 As New ADODB.Recordset
Dim sql1 As String
Set conn1 = CreateObject("adodb.connection")
conn1.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path + "\开发区中小学财务收支管理.mdb;Persist Security Info=False"
sql1 = "select Distinct * from 开发区中小学财务收支总表 where 学校名称 ='" & Combo2 & " 'and 年度 ='" & nd & " ' order by ID asc"
rs1.CursorLocation = adUseClient
rs1.Open sql1, conn1, adOpenStatic, adLockReadOnly, adCmdText
Set crRpt = crApp.OpenReport(App.Path + "\财务报表.rpt")
crRpt.DiscardSavedData
crRpt.Database.SetDataSource rs1, 3, 1
crRpt.Database.SetDataSource rs1, 3, 2
crRpt.EnableParameterPrompting = False
crRpt.SQLQueryString = sql1
CRViewer91.ReportSource = crRpt
CRViewer91.DisplayBackgroundEdge = False
CRViewer91.DisplayGroupTree = False
CRViewer91.Refresh
CRViewer91.ViewReport 报表 --------------------编程问答-------------------- sql1 = "select Distinct * from 开发区中小学财务收支总表 where 学校名称 ='" & Combo2 & " 'and 年度 ='" & nd & " ' order by ID asc"
开发区中小学财务收支总表
你打看一下这个表的原始数据,应该是视图吧,可能是关联写不对 --------------------编程问答--------------------
'调用两次,为什么?'
crRpt.Database.SetDataSource rs1, 3, 1
crRpt.Database.SetDataSource rs1, 3, 2
补充:VB , 数据库(包含打印,安装,报表)