-1

我在使用 vb 6.0 调用水晶报表 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
4

2 回答 2

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
于 2012-04-24T06:51:55.107 回答
0

导入 CrystalDecisions.CrystalReports.Engine Dim rpt 作为新的 ReportDocument rpt.Load(Application.StartupPath + "\Report\VariableReport.rpt") rpt.SetDataSource(rs)

于 2016-08-16T11:09:28.747 回答