Click here to Skip to main content
Click here to Skip to main content

Passing Parameters to Crystal Reports at Runtime

By , 20 Nov 2003
 

Introduction

This article describes how to get and set the parameter value from the report:

Crystal_net_parameters.jpg

Example

This example is composed of:

  1. A sample report 

  2. A form that loads the report automatically and shows the preview report

  3. A button that retrieves the parameter's actual value using the method:

    private string GetParamValue (string paramName)
    {
        string tmpValue="";
        for(int i=0;i<ReportDoc.DataDefinition.FormulaFields.Count; i++)
        {
            if(ReportDoc.DataDefinition.FormulaFields[i].FormulaName==
    						"{" + paramName + "}")
            tmpValue= ReportDoc.DataDefinition.FormulaFields[i].Text ;
        }
        return tmpValue;
    }
  4. Another button that changes the values of the report using the textbox text:

    private void SetParamValue (string paramName, string paramValue)
    {
        for(int i=0;i<ReportDoc.DataDefinition.FormulaFields.Count; i++)
        if(ReportDoc.DataDefinition.FormulaFields[i].FormulaName==
    					"{" + paramName + "}")
        ReportDoc.DataDefinition.FormulaFields[i].Text = "\"" +paramValue +"\"";
    }

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

gfajardo
Software Developer (Senior) Claro Colombia
Colombia Colombia
Member
German A. Fajardo G.
Web Developper
SQL Server Developer
PL/SQL Developer
Business Intelligence Desiggn Developer
ITIL Services Implementation.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralMy vote of 3memberJackson K T16 Aug '12 - 20:10 
GeneralMy vote of 5memberpremkumar.r29 Jul '11 - 0:06 
GeneralMy vote of 2memberinamgul26 Apr '11 - 20:48 
GeneralMy vote of 5memberadnanrehmankhan19 Jul '10 - 0:02 
Generalchange the report's font at run timememberda_dhanaraj3 Nov '08 - 8:09 
GeneralExcellent!memberBit-Smacker9 Sep '08 - 9:18 
Generalthanxmembersajat29 Apr '08 - 2:05 
GeneralThanksmemberzaider2 Apr '08 - 9:17 
GeneralThankmemberEscocia12 Jun '07 - 1:05 
GeneralWin Forms Grid Data and moresussAnonymous10 Apr '05 - 23:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web03 | 2.6.130516.1 | Last Updated 21 Nov 2003
Article Copyright 2003 by gfajardo
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid