s = s & " SELECT " & Val(glid) & " as A,'" & ComputerName & "'as S,id, 业户名称, 许可证号, CONVERT(varchar(10),许可证批准日期,102), 联系电话, 审验年度,运输类别"
s = s & " From 业户档案"
s = s & " Where (审验年度 Is Null Or 审验年度 < " & Val(nd) & ")"
If gldw <> "全部" Then
s = s & " And (管理单位id = " & gldw.ItemData(gldw.ListIndex) & ")"
End If
If tjfl <> "全部" Then
s = s & " and 业户档案." & tjfl.Text & "=1"
End If
s = s & " ORDER BY [业户档案].id;"
cn.Execute s
上边就是你说的那种情况。如果GLDW是空的话,就不筛选,否则就按照用户填写的筛选。
在報表中創建一個公式,此公式中默認一個組的欄位,插入一組(組名是此公式)
VB中動態指定此公式的內容:rpt1是控件名稱
rpt1.Formulas(1)={RptTable.groupField}注意公式的次序
排序:
rpt1.SortFields(1) = "+{RptTable.groupField}"
也可以用完全代碼實現:
Dim cryApp As New CRAXDRT.Application
Dim Report As CRAXDRT.Report
Set Report = cryApp.OpenReport("E:\report1.rpt")
Report.AddGroup