我在使用vb 6.0调用crystal report 8.5时遇到问题。我不知道如何使用vb调用该报告。这是我写的代码示例
Private Sub Command1_Click()
openConnection
If Me.cmbMonth = "" And Me.cmbYear = "" Then
MsgBox "Please select MONTH and YEAR"
Exit Sub
End If
Set rs = New ADODB.Recordset
With crp
.ReportFileName App.Path & "\Report\VariableReport.rpt"
.WindowTitle "Report"
End With
End Sub
答案 0 :(得分:0)
Dim tbl As CRAXDDRT.DatabaseTable
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim m_rpt As String
m_rpt = rs("Path") + "AnalysisCodeList2.rpt"
crystalrpt.reportfilename = m_rpt
crystalrpt.connect = rs("RptConnect")
crystalrpt.ParameterFields(0) = "PrintUser;" & m_curUser & ";true"
crystalrpt.ParameterFields(1) = "AnalysisCategory;" & CStr(Nz(cboAnalysisCategory.Value, "")) & ";true"
If Nz(cboAccountCodeTo.Value, "") <> "" And Nz(cboAccountCodeFm.Value, "") = "" Then
crystalrpt.ParameterFields(2) = "AnalysisCodeRangeStart;" & CStr(Nz(cboAccountCodeFm.ItemData(0), "")) & ";true"
crystalrpt.ParameterFields(3) = "AnalysisCodeRangeEnd;" & CStr(Nz(cboAccountCodeTo.Value, "")) & ";true"
Else
crystalrpt.ParameterFields(2) = "AnalysisCodeRangeStart;" & CStr(Nz(cboAccountCodeFm.Value, "")) & ";true"
crystalrpt.ParameterFields(3) = "AnalysisCodeRangeEnd;" & CStr(Nz(cboAccountCodeTo.Value, "")) & ";true"
End If
crystalrpt.ParameterFields(4) = "AnalysisCodeFilter;" & CStr(Replace(Nz(txtAccountCodeFilter.Value, ""), "*", "~")) & ";true"
crystalrpt.ParameterFields(5) = "MatchCase;" & CStr(Nz(txtMatchCase.Value, "")) & ";true"
crystalrpt.ParameterFields(6) = "Description;" & CStr(Nz(txtDescription.Value, "")) & ";true"
crystalrpt.Action = 1
答案 1 :(得分:0)
导入CrystalDecisions.CrystalReports.Engine Dim rpt As New ReportDocument rpt.Load(Application.StartupPath +“\ Report \ VariableReport.rpt”) rpt.SetDataSource(RS)