通过vb程序传递记录集给水晶报表控件
通过vb程序传递记录集给水晶报表控件,初学者,很多疑惑,一般要定义什么,怎么传递参数和公式Option Explicit
Dim crpParamDefs As CRAXDRT.ParameterFieldDefinitions(什么时候需要定义ParameterFieldDefinitions)
Dim crpParamDef As CRAXDRT.ParameterFieldDefinition
Dim rptAP As New CRAXDRT.Application
Dim rptReport As New CRAXDRT.Report
Dim crSections As CRAXDRT.Sections(什么时候需要定义Sections)
Dim crSection As CRAXDRT.Section
Dim crSubReportObjs As CRAXDRT.ReportObjects
Dim crSubReportObj As CRAXDRT.SubreportObject
Dim crSubReport As CRAXDRT.Report
Dim crSectionOptions As CRAXDRT.Section
Dim crExportOption As CRAXDRT.ExportOptions
Private Sub Form_Load()
Dim SourceFile As String
Dim X As Integer
Dim Y As Integer
Screen.MousePointer = vbHourglass
If FrmMesWipR309.Combotype.Text = "Details" Then(这段代码是什么意思)
If Right(App.Path, 1) <> "\" And Right(App.Path, 1) <> "/" Then
SourceFile = Trim(App.Path) & "\Report\MesWipR309.rpt"
Else
SourceFile = Trim(App.Path) & ".\Report\MesWipR309.rpt"
End If
Else
If Right(App.Path, 1) <> "\" And Right(App.Path, 1) <> "/" Then
SourceFile = Trim(App.Path) & "\Report\MesWipR309_1.rpt"
Else
SourceFile = Trim(App.Path) & ".\Report\MesWipR309_1.rpt"
End If
End If
FrmReportR309.WindowState = 2 '窗口最大化
Set rptReport = rptAP.OpenReport(SourceFile)
rptReport.Database.Tables(1).SetDataSource TTXRs, 3
Set crpParamDefs = rptReport.ParameterFields(这段代码是什么意思,是传递参数给rpt文件吗?)
For Each crpParamDef In rptReport.ParameterFields
With crpParamDef
Select Case .ParameterFieldName
Case "mat"
.AddCurrentValue mat
Case "mattype"
.AddCurrentValue mattype
Case "user"
.AddCurrentValue puser
End Select
End With
Next
CRViewer1.ReportSource = rptReport
CRViewer1.ViewReport '//显示报表
Screen.MousePointer = vbDefault
End Sub
Private Sub Form_Resize()
CRViewer1.Top = 0
CRViewer1.Left = 0
CRViewer1.Height = ScaleHeight
CRViewer1.Width = ScaleWidth
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set crpParamDefs = rptReport.ParameterFields
For Each crpParamDef In rptReport.ParameterFields
With crpParamDef
Select Case .ParameterFieldName
Case "mat"
.ClearCurrentValueAndRange
Case "mattype"
.ClearCurrentValueAndRange
Case "pUser"
.ClearCurrentValueAndRange
End Select
End With
Next
Set crpParamDef = Nothing
Set crpParamDefs = Nothing
Set rptReport = Nothing
TTXRs.Close
Set TTXRs = Nothing
End Sub
--------------------编程问答-------------------- 怎么没有人回复呢?
补充:VB , 数据库(包含打印,安装,报表)