So sánh crystal reports 9.0 và crystal reports 9.2

Ok, I have setup my report all from within the report. The database, the stored procedure, and the fields I'm going to display.

My question is: How can I do to display the report by passing the parameters through VB6?

I already have added Crystal Reports 9 ActiveX Designer RunTime Library and Crystal Reports Viewer 9 to References as well as Crystal Report Viewer 9 to Components.

Hope you can help me figure this out.

Marcelo.


  • Feb 1st, 2006, 03:48 PM

    Re: Crystal Reports 9.2 and Stored Procedures problem Use the CRAXDRT objects to set the parameters (and anything else you need, like login information).

    This sample code Opens, Sets two Parameters and then Shows the report on a Form that contains the Crystal Viewer control. In this case the two parameters are "Discrete" Date values that the user chosen from Date Picker controls.

    VB Code:

    1. Dim objCrystal As CRAXDRT.Application 'its better to create this object global to the VB application.
    2. Dim objReport As CRAXDRT.Report
    3. Dim objParam As CRAXDRT.ParameterFieldDefinition
    4. Set objCrystal = New CRAXDRT.Application
    5. Set objReport = objCrystal.OpenReport(FileName, 1)
    6. Set objParam = objReport.ParameterFields.GetItemByName("@FromDate")
    7. objParam.ClearCurrentValueAndRange
    8. objParam.AddCurrentValue dtpFromDate.Value
    9. Set objParam = objReport.ParameterFields.GetItemByName("@ToDate")
    10. objParam.ClearCurrentValueAndRange
    11. objParam.AddCurrentValue dtpToDate.Value
    12. With frmReportViewer
    13. If Len(ReportTitle) > 0 Then
    14. .Caption = ReportTitle
    15. End If
    16. .ReportViewer.ReportSource = objReport
    17. .ReportViewer.ViewReport
    18. .Show
    19. .ZOrder vbBringToFront
    20. End With

    Note I only have Crystal 8.5 but the code should be similar for 9.

    -
    • Feb 2nd, 2006, 06:57 AM

      So sánh crystal reports 9.0 và crystal reports 9.2
      Thread Starter Member
      So sánh crystal reports 9.0 và crystal reports 9.2

      -

      Re: Crystal Reports 9.2 and Stored Procedures problem

      Hi Bruce, I'm trying to figure out your code. And I think that is for filling a report indicating field and value, right? But... I already have all parameters setup at the file.rpt report such as database connection, stored procedure (which has a big sql query) and of course the fields resulting from that stored procedure which are set at the report designer. This stored procedure accepts two parameters which has nothing to do with fields. They are numeric and they act as follows: if prm1=0 and prm2=0 then do something; if prm1=0 and prm2=1 then do something else... and so on...

    Hope you understand me and can help me figure this out.

    Thanks, Marcelo.


    • Feb 2nd, 2006, 11:06 AM

      Re: Crystal Reports 9.2 and Stored Procedures problem

      My code shows you how to pass parameter values from a VB 6 application to the Crystal Report and then show the report. The Report.ParameterFields collection is used to set the value of the parameters that you created in your rpt file. When the line .ReportViewer.ViewReport is called the Crystal Runtime library takes over and the report is generated. Crystal Reports is a business intelligence application marketed to small- and medium-sized businesses by SAP.

      History[edit]

      Terry Cunningham and the Cunningham Group originated the software in 1984. Crystal Services Inc. marketed the product (originally called "Quik Reports") when they could not find a suitable commercial report writer for an accounting software they developed add-on products for, which was ACCPAC Plus for DOS (later acquired by Sage). After producing versions 1.0 through 3.0, Crystal Services was acquired by Seagate Technology in 1994. Crystal Services was combined with Holistic Systems to form the Information Management Group of Seagate Software, which later rebranded as Crystal Decisions and produced versions 4.0 through 9.0. Crystal Decisions was acquired in December 2003 by BusinessObjects, which produced versions 10, 11 (XI) and version 12 (2008). SAP acquired BusinessObjects on October 8, 2007, and released Crystal Reports 2011 (version 14) on May 3, 2011. The latest version released is Crystal Reports 2020 (14.3.x) on June 13, 2020. The file extension for Crystal Reports' proprietary file format is .rpt. The design file can be saved without data, or with data for later viewing or sharing. Introduced with the release of Crystal Reports 2011 (version 14.0), the read-only .rptr file extension option allows for viewing, but cannot be modified once exported.