Results 1 to 7 of 7

Thread: pass parameters to Crystal Reports?

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2000
    Posts
    8

    Exclamation Pass parameters to Crystal Reports 8 ???

    Hi,
    I'm using Visual Basic 6.0 and Seagate Crystal Reports 8. I want to view a report called from Visual Basic. The report is made in Crystal Reports and has some parameters. Now, my question is: How can I pass parameters through Visual Basic to call my report.
    Second problem: I open my report in the ActiveX viewer an I get the first page from my report. If I try to refresh my parameters, or if I try to go to the second page, I get the error : "Server has not yet been opened".
    Please, need urgent help, desperate!!

    Thanks very much,

    Billy.

    [Edited by Billy on 11-27-2000 at 02:46 AM]

  2. #2
    Fanatic Member faisalkm's Avatar
    Join Date
    Oct 2000
    Location
    Germany
    Posts
    752

    Cool Hi

    You can use the 'selectioformula' property of the crystal report control to filter the data. In order to pass parameters the logic i use is to create a field(not a database field) and leave it as blank. In the crystal report write a query to include this value as a condition. And from vb assign a value to this field and then show the report

    Faisal
    Faisal Muhammed
    Homepage:I Started making it in 1994 ...Still Under Construction
    Using

    Visual Basic 6.0 Enterprise SP5
    Embedded Visual Basic 3.0
    SQL Server 2000
    Windows 2000 Proff
    Delphi 6.0


    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

  3. #3
    Hyperactive Member
    Join Date
    Jul 2000
    Location
    Halifax,UK
    Posts
    274
    heres some code that may help...


    Dim m_objReport As CRAXDRT.Report
    Dim m_objApp As New CRAXDRT.Application
    Dim params As CRAXDRT.ParameterFieldDefinitions
    Dim param As CRAXDRT.ParameterFieldDefinition

    Set m_objReport = m_objApp.OpenReport("REPORTNAME", 1)

    m_objReport.EnableParameterPrompting = False
    m_objReport.Database.SetDataSource DATASOURCED
    m_objReport.Database.Verify
    m_objReport.ReadRecords

    Set params = m_objReport.ParameterFields

    For Each param In params
    With param
    .ClearCurrentValueAndRange
    .AddCurrentValue EACHVALUEHERE
    End With
    Next

    With lgfgReport
    .ReportSource = m_objReport
    .ViewReport
    .Zoom 1
    End With



    Regards

    Chris
    VB6 VS2005

  4. #4

    Thread Starter
    New Member
    Join Date
    May 2000
    Posts
    8

    Talking

    Thanks. I tried the code, but then I get the error: "Server has not yet been opened". What exactly do you mean with 'DATASOURCED' and what is 'lgfgReport'?

  5. #5
    Fanatic Member faisalkm's Avatar
    Join Date
    Oct 2000
    Location
    Germany
    Posts
    752

    Talking

    Hey,

    If u r using the crystal report control, then u should connect to the server using the connect property of the Crystal report control
    Faisal Muhammed
    Homepage:I Started making it in 1994 ...Still Under Construction
    Using

    Visual Basic 6.0 Enterprise SP5
    Embedded Visual Basic 3.0
    SQL Server 2000
    Windows 2000 Proff
    Delphi 6.0


    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

  6. #6

    Thread Starter
    New Member
    Join Date
    May 2000
    Posts
    8

    Unhappy

    I am using the 'Crystal Report Viewer Control'. This has no connect property. I'm making a connection as followes:
    con = "Provider=OraOLEDB.Oracle.1;Persist Security Info=False;Data Source=orcl"
    con.ConnectionTimeout = 300
    con.CommandTimeout = 300
    con.Mode = adModeRead
    con.IsolationLevel = adXactReadCommitted
    con.CursorLocation = adUseClient
    con.Open con, "userid", "password"
    Set crxApp = New CRAXDRT.Application

    If I call my report without trying to pass parameters, the CRViewer is showing the report. If I try to pass parameters with the following code, I get the error "Server has not yet been opened".

    Set crxReport = crxApp.OpenReport("C:\path\report.rpt")
    Set crxParameterFieldDefinitions = crxReport.ParameterFields
    Set crxDatabase = crxReport.Database
    Set crxDatabaseTables = crxDatabase.Tables
    For Each crxDatabaseTable In crxDatabaseTables
    Set DatabaseTable = crxDatabaseTable
    Exit For
    Next crxDatabaseTable
    DatabaseTable.SetLogOnInfo "test", "test", "userid", "password"
    For Each crxParameterFieldDefinition In crxReport.ParameterFields
    Select Case crxParameterFieldDefinition.Name
    Case "{?code}"
    crxParameterFieldDefinition.ClearCurrentValueAndRange
    crxParameterFieldDefinition.AddCurrentValue CStr(code.Text)
    End Select
    Next

    Can somebody help me, please??

    Billy



  7. #7
    Hyperactive Member
    Join Date
    Jul 2000
    Location
    Halifax,UK
    Posts
    274
    DATASOURCED should read DATASOURCE, this is the name of your recordset.

    lgfgreport is the name of my report control.

    EACHVALUEHERE should be replaced by your parameter values
    (a different itteration loop could be used.

    REPORTNAME is the path and name of your report.

    Regards

    Chris
    VB6 VS2005

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width