Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Pass Start and End Date Parameter to Crystal Report
Message
Information générale
Forum:
ASP.NET
Catégorie:
Rapports
Divers
Thread ID:
01029938
Message ID:
01030047
Vues:
16
This message has been marked as the solution to the initial question of the thread.
I fixed the problems and now everything works to pass start and end date parameters to my Crystal Report in VB.NET...

Here is the wild and crazy code that actually works to pass parameters to a Crystal Report from VB.NET app (front-end menu to Crystal Reports) so users can choose a report from a menu and run it. If the report has start and end date parameters, this code plugs them into the report and preview the report in a form's window that contains a Crystal Reports Viewer object...
    Dim crxApplication As New CRAXDRT.Application
    Public oReport As CRAXDRT.Report
    Public cboRpt1, cboRpt2 As String
    Public start_date, end_date As String

    Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        If cboRpt1 = 0 And cboRpt2 = 0 Then
            oReport = crxApplication.OpenReport("c:\crystal_test.rpt", 1)
            oReport.ParameterFields.Item(1).AddCurrentValue(CDate(F1.TextBox2.Text))
            oReport.ParameterFields.Item(2).AddCurrentValue(CDate(F1.TextBox3.Text))
        ElseIf cboRpt1 = 0 And cboRpt2 = 1 Then
            oReport = crxApplication.OpenReport("c:\crystal_test.rpt", 1)
            oReport.ParameterFields.Item(1).AddCurrentValue(CDate(F1.TextBox2.Text))
            oReport.ParameterFields.Item(2).AddCurrentValue(CDate(F1.TextBox3.Text))
        ElseIf cboRpt1 = 0 And cboRpt2 = 2 Then
            oReport = crxApplication.OpenReport("c:\crystal_test.rpt", 1)
            oReport.ParameterFields.Item(1).AddCurrentValue(CDate(F1.TextBox2.Text))
            oReport.ParameterFields.Item(2).AddCurrentValue(CDate(F1.TextBox3.Text))
        ElseIf cboRpt1 = 1 And cboRpt2 = 0 Then
            oReport = crxApplication.OpenReport("c:\crystal_test.rpt", 1)
        ElseIf cboRpt1 = 1 And cboRpt2 = 1 Then
            oReport = crxApplication.OpenReport("c:\crystal_test.rpt", 1)
        ElseIf cboRpt1 = 1 And cboRpt2 = 2 Then
            oReport = crxApplication.OpenReport("c:\crystal_test.rpt", 1)
        ElseIf cboRpt1 = 1 And cboRpt2 = 3 Then
            oReport = crxApplication.OpenReport("c:\crystal_test.rpt", 1)
            oReport.ParameterFields.Item(1).AddCurrentValue(CDate(F1.TextBox2.Text))
            oReport.ParameterFields.Item(2).AddCurrentValue(CDate(F1.TextBox3.Text))
        ElseIf cboRpt1 = 1 And cboRpt2 = 4 Then
            oReport = crxApplication.OpenReport("c:\crystal_test.rpt", 1)
            oReport.ParameterFields.Item(1).AddCurrentValue(CDate(F1.TextBox2.Text))
            oReport.ParameterFields.Item(2).AddCurrentValue(CDate(F1.TextBox3.Text))
        ElseIf cboRpt1 = 2 And cboRpt2 = 0 Then
            oReport = crxApplication.OpenReport("c:\crystal_test.rpt", 1)
        ElseIf cboRpt1 = 2 And cboRpt2 = 1 Then
            oReport = crxApplication.OpenReport("c:\crystal_test.rpt", 1)
        ElseIf cboRpt1 = 2 And cboRpt2 = 2 Then
            oReport = crxApplication.OpenReport("c:\crystal_test.rpt", 1)
        ElseIf cboRpt1 = 2 And cboRpt2 = 3 Then
            oReport = crxApplication.OpenReport("c:\crystal_test.rpt", 1)
        ElseIf cboRpt1 = 2 And cboRpt2 = 4 Then
            oReport = crxApplication.OpenReport("c:\crystal_test.rpt", 1)
        ElseIf cboRpt1 = 2 And cboRpt2 = 5 Then
            oReport = crxApplication.OpenReport("c:\crystal_test.rpt", 1)
        End If

        crViewer.ReportSource = oReport
        crViewer.ViewReport()
    End Sub
Steve Kramer
Kramer & Kramer Design
"Home of Go Cartoons"
Web Site: www.stephenkramer.com
Would you believe Far Side Lite?
More than 270 original cartoons.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform