Pass parameters from VB to crystal report

Posted on 2005-05-03
Last Modified: 2010-05-18

How can I connect a report created in Crystal report 8.0 with VB using RDC and pass parameters? I want to change my connection parameters at runtime.

Question by:Seejaanilkumar
    LVL 100

    Accepted Solution


    Author Comment

    Thanks for ur response. I am not getting the above site. Anyway I found a solution by myself.

    LVL 100

    Expert Comment

    What was your solution?


    Author Comment

    The following is the solution.

    Dim LNI_I As Integer
    Dim LCRX_SubReport As CRAXDRT.Report
    Dim LUO_Object As Object
    Dim LCRX_Section As CRAXDRT.Section
    Dim LCRX_SubReportObject As CRAXDRT.SubreportObject
    Set WCRX_Application = CreateObject("CrystalRunTime.Application")
    Set WCRX_Report = WCRX_Application.OpenReport(App.Path & LNS_ReportName)
    For LNI_I = 1 To WCRX_Report.Database.Tables.Count
        WCRX_Report.Database.Tables.Item(LNI_I).SetLogOnInfo GNS_Dsn, , GNS_DbUserId, GNS_DbPswd
    For Each LCRX_Section In WCRX_Report.Sections
        For Each LUO_Object In LCRX_Section.ReportObjects
            If LUO_Object.Kind = crSubreportObject Then
                Set LCRX_SubReportObject = LUO_Object
                Set LCRX_SubReport = LCRX_SubReportObject.OpenSubreport
                For LNI_I = 1 To LCRX_SubReport.Database.Tables.Count
                    LCRX_SubReport.Database.Tables.Item(LNI_I).SetLogOnInfo GNS_Dsn, , GNS_DbUserId, GNS_DbPswd
            End If
        Next LUO_Object
    Next LCRX_Section
    WCRX_Report.ParameterFields.Item(1).AddCurrentValue DTP_Date.Value
    CRV_Report.ReportSource = WCRX_Report
    Set WCRX_Report = Nothing


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
    Article by: Martin
    Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now