Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > Crystal Reports
|
Crystal Reports General discussion about Crystal Reports. For discussions specific to the book Professional Crystal Reports for VS.NET, please see the book discussion forum for that book.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Crystal Reports section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 14th, 2005, 12:51 AM
Registered User
 
Join Date: Jan 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default crystal report parameter

i am working on crystal report.net.(vb.net and sql server)
i have created a date parameter of type date (Option- discrete value),
when i use it on the report the value chosen by the user at runtime is displayed on the report, but the same doed not happen when i use option - range value for the date parameter.
 i want the range value chosen at runtime by the user to be displayed in the report.
please can anyone help me in this.
 thanks in advance
 ravi

 
Old February 18th, 2005, 06:47 PM
Authorized User
 
Join Date: Aug 2004
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The best way I have found to do this is rather than using a range is to have 2 parameter fields i.e. a start date and a finish date. You then insert both fields in your report as per usual.

   Regards,
   narooma :)

 
Old February 25th, 2005, 02:05 AM
Registered User
 
Join Date: Jan 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thank you narooma, by the way i found a solution , i worked it out using formulas.
Quote:
quote:Originally posted by narooma.12
 The best way I have found to do this is rather than using a range is to have 2 parameter fields i.e. a start date and a finish date. You then insert both fields in your report as per usual.

Regards,
narooma :)

 
Old February 26th, 2005, 02:32 AM
Registered User
 
Join Date: Feb 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can programmatically pass parameter values into your Crystal Report using VB.NET code similar to this:
    Imports CrystalDecisions.CrystalReports.Engine
    Imports CrystalDecisions.Shared
    '
    ' Load the selected report file.
    '
    Dim CR As New ReportDocument
    CR.Load(strReportPath)
    '
    ' Declare the parameter related objects.
    '
    Dim crParameterDiscreteValue As ParameterDiscreteValue
    Dim crParameterFieldDefinitions As ParameterFieldDefinitions
    Dim crParameterFieldLocation As ParameterFieldDefinition
    Dim crParameterValues As ParameterValues
    '
    ' Get the report's parameters collection.
    '
    crParameterFieldDefinitions = CR.DataDefinition.ParameterFields
    '
    ' Set the first parameter
    ' - Get the parameter, tell it to use the current values vs default value.
    ' - Tell it the parameter contains 1 discrete value vs multiple values.
    ' - Set the parameter's value.
    ' - Add it and apply it.
    ' - Repeat these statements for each parameter.
    '
    crParameterFieldLocation = crParameterFieldDefinitions.Item("StartDate")
    crParameterValues = crParameterFieldLocation.CurrentValues
    crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue
    crParameterDiscreteValue.Value = strStartDate
    crParameterValues.Add(crParameterDiscreteValue)
    crParameterFieldLocation.ApplyCurrentValues(crPara meterValues)
    '
    ' Set the Crytal Report Viewer control's source to the report document.
    '
    CrystalReportViewer.ReportSource = CR
If your report's DataSource is a .NET DLL DO NOT set the ReportDocument's DataSource property programatically as in the code below. However, if the DataSource is an XML Schema (.xsd) file you must set it prior to setting your parameters.
    cr.SetDataSource(DS.Tables("Customer"))
If your report's DataSource is a .NET DLL as shown here and the public functions that return the datatables available to your report where changed to require parameters, as illustrated below, the parameters can be set as just described.
    Public Function Customers(theStartDate As String) As DataTable
If the parameters were added to your Crystal Report by clicking the Parameter Fields node in the Crystal IDE's Field Explorer they can be set using the following code:
    Dim cr As New ReportDocument
    cr.Load(strReportPath)
    cr.SetDataSource(DS.Tables("Customers"))
    cr.SetParameterValue("StartDate", strMyParmValue)
    CrystalReportViewer.ReportSource = cr


Quote:
quote:Originally posted by sportforever
 i am working on crystal report.net.(vb.net and sql server)
i have created a date parameter of type date (Option- discrete value),
when i use it on the report the value chosen by the user at runtime is displayed on the report, but the same doed not happen when i use option - range value for the date parameter.
i want the range value chosen at runtime by the user to be displayed in the report.
please can anyone help me in this.
thanks in advance
ravi

 
Old April 10th, 2008, 03:32 AM
Registered User
 
Join Date: Apr 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

First you have to create parameter field in Crystal report

from program you code like this,

        Dim crParameterFieldDefinitions As ParameterFieldDefinitions
        Dim crParameterFieldDefinition As ParameterFieldDefinition
        Dim crParameterValues As New ParameterValues
        Dim crParameterDiscreteValue As New ParameterDiscreteValue

        crParameterDiscreteValue.Value = "your date value here"

refer this

http://vb.net-informations.com/cryst...meter_date.htm

regards






Similar Threads
Thread Thread Starter Forum Replies Last Post
pass parameter in crystal report srivigdev C# 3 April 14th, 2008 12:11 PM
crystal report parameter angelboy C# 2005 2 April 22nd, 2007 07:59 AM
Crystal Report Parameter sujah.s ASP.NET 1.0 and 1.1 Basics 0 May 29th, 2006 04:59 AM
Crystal Report Parameter BKunneke VB.NET 2002/2003 Basics 1 June 13th, 2005 09:47 AM
Crystal report, passing parameter suni_kutty Crystal Reports 2 October 7th, 2004 03:13 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.